mysql查询某字段相同的记录

mysql查询某字段相同的记录,第1张

select * from 表名 where match_id in (select match_id from 表名 where team_id='a' or team_id='b' group by match_id)

select * from tableName where (bookname,borrowtime) in (select bookname,borrowtime from tableName group by bookname,borrowtime having count(*) > 1)

场景:表中包含有group_id,worker_id,status字段,查询这三个字段是否存在重复的数据。

查找某个人在某个班组内存在多个status为0的数据

查找某个人在某个班组内存在多个status为0的数据,将最小的id选出来

查找某个人在某个班组内存在多个status为0的数据,将最小的id选出来,并设置status为1

将查询查询结果作为where in的条件,需要select的结果再通过一个中间表select多一次,否则会报You can't specify target table for update in FROM clause。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6136903.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-16
下一篇 2023-03-16

发表评论

登录后才能评论

评论列表(0条)

保存