我在循环里面查找数据,为什么把上一次的in条件会拼在一起?我想要的是每一个都新的单独查询,用什么方式。 code:

for _, userGroup := range userGroups {
    users := make([]*models.AlertUsers, 0)
    err := db.Table(AlertUsers).Where("id in ?", strings.Split(userGroup.UserIds, ",")).Find(&users).Error
    if err == nil {
        userGroup.UserIdsDetail = users
    }
}

runnig sql: 遍历第一个数据结果:SELECT * FROM users WHERE id in ('usr-fWNDQJ8a','usr-GAxB2bch') 遍历第二个数据结果:SELECT * FROM users WHERE id in ('usr-fWNDQJ8a','usr-GAxB2bch') AND id in ('usr-fWNDQJ8a','usr-GAxB2bch','usr-LqjKdmHS','usr-Rgwf7HLB','usr-LfXGa9nT') 遍历第三个数据结果:SELECT * FROM users WHERE id in ('usr-fWNDQJ8a','usr-GAxB2bch') AND id in ('usr-fWNDQJ8a','usr-GAxB2bch','usr-LqjKdmHS','usr-Rgwf7HLB','usr-LfXGa9nT') AND id in ('usr-fWNDQJ8a')

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: li-jin-gou

可以看下这个文档,https://gorm.cn/zh_CN/docs/method_chaining.html#%E6%96%B0%E5%BB%BA%E4%BC%9A%E8%AF%9D%E6%A8%A1%E5%BC%8F