I am trying to find multiple users based on their name. I am using gorm as follow:
err := db.Where("username IN ?", []string{"name1", "name2"}).Find(&users).Error
But the generated query is:
SELECT * FROM "users_customer"."user" WHERE (username IN 'name1','name2')
when the correct query should be:
SELECT * FROM "users_customer"."user" WHERE username IN ('name1','name2')
So the error pq: syntax error at or near "$1" is thrown. I use the same syntax as stated in the doc, which is db.Where("name IN ?", []string{"jinzhu", "jinzhu 2"}).Find(&users) but don't know why in my case it doesn't work.
IN (?)inside your String?