sql查詢某欄位的相同值: SELECT * FROM table WHERE col in (SELECT col FROM table GROUP BY col HAVING COUNT (col) >1); 順帶說一下where和having: select * from tablewhere ...
sql查詢某欄位的相同值: SELECT * FROM table WHERE col in (SELECT col FROM table GROUP BY col HAVING COUNT (col) >1); 順帶說一下where和having: select * from table
where ···(只能對分組前的屬性進行篩選)
group by ···(按某個欄位分組)
having ···(只能對分組後的每個組的整體屬性進行篩選,用聚合函數體現)
--不使用group by就預設表的整體為一組