包含查询
WhereIn()
可通过链式调用的方式来指定多条件的查询
- @param
field
字段名 - @param
value
值, 一般这里传一个数组
WhereIn()
var user []User
err := tg.Db("user").Where("age", "=", 10).WhereIn("tag", []interface{1, 2, 3}).Select(&user)
var user []User
err := tg.Db("user").Where("age", "=", 10).WhereIn("tag", []interface{1, 2, 3}).Select(&user)
最终的SQL语句为:
SELECT * FROM user WHERE age = 10 AND tag IN (1, 2, 3)
SELECT * FROM user WHERE age = 10 AND tag IN (1, 2, 3)