常用SQL
1.查找表中单个字段的值有哪些相同的记录:
假设表名是table,列名是column,则查询语句为:
SELECT * FROM table WHERE column IN (SELECT column FROM table GROUP BY column HAVING COUNT(column)>1)
2.查找表中多个字段的值有哪些相同的记录:
假设表名是table,列名是column1,列名column2,则查询语句为:
SELECT A.* FROM table A RIGHT JOIN (SELECT column1,column2 FROM table group by column1,column2 HAVING COUNT(*)>1 ) B ON A.column1 = B.cloumn1 AND A.column2 = B.column2
Comments | NOTHING