sql-select
Posted 每天一点积累
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章