SELECT 語句用于從表中選取數據。SELECT語句是查詢語法的核心,所有高級查詢語法都是圍繞SELECT語句展開的。本節將簡單支持的SELECT語句語法,高級用法請參考其他的小節。
語法格式
SELECT:
SELECT [ DISTINCT ]
{ * | projectItem [, projectItem ]* }
FROM tableExpression
[ WHERE booleanExpression ]
[ GROUP BY { groupItem [, groupItem ]* } ]
[ ORDER BY { orderByItem [, OrderByItem ]* }]
[ HAVING booleanExpression ]
[ LIMIT number]
[ OFFSET number]
projectItem:
expression [ [ AS ] columnAlias ]
| tableAlias . *
示例
SELECT * FROM table;
SELECT f1, f2 AS ff FROM table;
SELECT DISTINCT f FROM table;
SELECT * FROM (
SELECT f1, count(*) AS num
FROM t1
GROUP BY f1
) tt
WHERE tt.num > 100;
文檔內容是否對您有幫助?