首页 > 代码库 > sql-select
sql-select
SELECT column_1,column_2,... FROM table_1 [INNER|LEFT|RIGHT]JOINtable_2ONconditions WHERE conditions GROUPBYcolumn_1 HAVINGgroup_conditions ORDER BYcolumn_1 LIMIToffset,length;
select语法
HAVING 和 WHERE 区别:
The MySQL HAVING clause is often used with the GROUP BY clause. When using with the GROUP BY
clause, we can apply a filter condition to the columns that appear in the GROUP BY
clause. If the GROUP BY
clause is omitted, the HAVING
clause behaves like the WHERE clause.
Notice that the HAVING
clause applies the filter condition to each group of rows, while the WHERE
clause applies the filter condition to each individual row.
subquery:
SELECT orderNumber, customerNumber, status, shippedDate FROM orders WHERE orderNumber IN (SELECT orderNumber FROM orderDetails GROUP BY orderNumber HAVING SUM(quantityOrdered * priceEach) > 60000);
sql-select
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。