sql query for the same value of a certain field:
SELECT * FROM table WHERE col in (SELECT col FROM table GROUP BY col HAVING COUNT (col) >1);
By the way, where and having:
select * from table
where ···(Only attributes before grouping can be filtered)
group by ···(Group by a certain field)
having ···(Only Filter the overall attributes of each group after grouping and use aggregate functions)
--If you don’t use group by, the entire table will be a group by default
The above is the detailed content of SQL query for the same value of a field. For more information, please follow other related articles on the PHP Chinese website!