0

I have list of array int64 values

ids = [{1} {2} {3}]

I want to use the above array in db query to filter out the records where ID is not in above ids.

SELECT * from table where id not in (1,2,3);

I tried many ways to do but failing to make the query string.

1
  • Can you provide an example of how you trying to solve the problem? and provide a valid syntax like ids := []int{1,2,3} Commented Dec 6, 2021 at 8:42

1 Answer 1

1

I have created a sample scenario as follows :

func main() {
    ids := []int{1, 2, 3}

    var tmp []string

    for _, v := range ids {
        tmp = append(tmp, fmt.Sprint(v))
    }

    query := "SELECT * from table where id not in (" + strings.Join(tmp, ",") + ")"
    fmt.Println(query)

}

OR

You can run it in go playground link

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.