The same record value of SQL lookup table fields

1. Find the value of a single field of the same record in the table which are:

Suppose the table name table, the column name column, the query is:

SELECT * FROM table WHERE column IN (SELECT column FROM table GROUP BY column HAVING COUNT(column)>1)

 

2. What are the same value record lookup table has a plurality of fields:

Suppose the table name table, the column name is column1, column names column2, the query is:

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

 

First find the record field 1, field 2 of the same value, B alias, then connected by a right, to find the same fields in the data 2 field 1.

Guess you like

Origin www.cnblogs.com/yaoze2018/p/11355383.html