Skip to content

范围查询


WhereBetween()

可通过链式调用的方式来指定多条件的查询

  • @param field 字段名
  • @param start 值1
  • @param end 值2

WhereBetween()

var user []User
err := tg.Db("user").Where("age", "=", 10).WhereBetween("score", 60, 80).Select(&user)
var user []User
err := tg.Db("user").Where("age", "=", 10).WhereBetween("score", 60, 80).Select(&user)

最终的SQL语句为:

SELECT * FROM user WHERE age = 10 AND score BETWEEN 60 AND 80
SELECT * FROM user WHERE age = 10 AND score BETWEEN 60 AND 80

备案号:冀ICP备20015584号-5