1
gorm.DB.Where("id in (?)", IDs).Find(&us)

If my IDs is []int{1,1} and I want to return the two duplicate data,How can I do? In my project if the IDs is []int{1,1} it only return to me one data

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
HarrisHan
  • 164
  • 2
  • 13
  • But since it’s duplicated, you can use a db.Where(“id = ?”, 1).find(&us) . If the “id” is a primary key, you can use db.Where(IDs).find(&us). – Fontinalis Nov 07 '17 at 10:15
  • Could you tell us more context and data examples ? This might help you : https://stackoverflow.com/questions/2594829/finding-duplicate-values-in-a-sql-table – kenfire Nov 17 '17 at 08:30

0 Answers0