做用:在 SQL 中增長 HAVING 子句緣由是,WHERE 關鍵字沒法與統計函數一塊兒使用。sql
以下查詢功能可用having子句
ide
- select company, count(employee) cnt
- from works t
- where salary>5000
- group by company
- having cnt>1
與使用中間表SQL相比性能差異巨大:函數
- select company
- from (select company, count(employee) cnt from works where salary>5000 group by company) t
- where cnt>1
使用MySQL Workbanch 的Explain結果:性能