Home  >  Article  >  Database  >  SQL query for the same value of a field

SQL query for the same value of a field

PHP中文网
PHP中文网Original
2017-06-19 10:47:102780browse
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn