有没有 id in (?)的用法?
试了一下,貌似没有 db.Table("table").Where("id IN(?)", ids).All(&user) 貌似不能这样用,最后自己拼接字符串用的。 不知道什么时候能支持 in的用法
你可以直接写 db.Table("table").Where("id IN(1,2,3,4)").All(&user)
alpiny [email protected] 于2019年11月22日周五 上午12:38写道:
试了一下,貌似没有 db.Table("table").Where("id IN(?)", ids).All(&user) 貌似不能这样用,最后自己拼接字符串用的。 不知道什么时候能支持 in的用法
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xiuno/dbx/issues/2?email_source=notifications&email_token=AAZU3ZLYNDAXB54TRMSF2Q3QU22QNA5CNFSM4JQFCAPKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H3E654A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZU3ZIJJ46IT3QY35M4ZXTQU22QNANCNFSM4JQFCAPA .
id 如果为整形,可以转为字符串,然后拼接下字符串。 后面可以考虑加上辅助函数,感谢建议。
master 版本已经支持了这个语法: db.Table("table").Where("id IN(?)", ids).All(&userList)