W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
query:
select:
SELECT [ ALL | DISTINCT ]
{ * | projectItem [, projectItem ]* }
FROM tableExpression
[ WHERE booleanExpression ]
[ GROUP BY { groupItem [, groupItem ]* } ]
[ HAVING booleanExpression ]
selectWithoutFrom:
SELECT [ ALL | DISTINCT ]
{ * | projectItem [, projectItem ]* }
projectItem:
expression [ [ AS ] columnAlias ]
| tableAlias . *
tableExpression:
tableReference [, tableReference ]*
| tableExpression [ NATURAL ] [ ( LEFT | RIGHT | FULL ) [ OUTER ] ] JOIN tableExpression [ joinCondition ]
| tableExpression CROSS JOIN tableExpression
| tableExpression [ CROSS | OUTER ] APPLY tableExpression
joinCondition:
ON booleanExpression
| USING '(' column [, column ]* ')'
tableReference:
tablePrimary
[ [ AS ] alias [ '(' columnAlias [, columnAlias ]* ')' ] ]
|tablePrimary:
[ [ catalogName . ] schemaName . ] tableName
'(' TABLE [ [ catalogName . ] schemaName . ] tableName ')'
|values:
VALUES expression [, expression ]*
groupItem:
expression
| '(' ')'
| '(' expression [, expression ]* ')'
SELECT UNION [ALL | DISTINCT] SELECT ...
when case語法
CASE case_value
WHEN booleanExpression THEN expression
[WHEN booleanExpression THEN expression] ...
[ELSE expression]
END CASE
會(huì)轉(zhuǎn)發(fā)sql
生成的sql
模板會(huì)帶有for update
語句,在涉及多個(gè)存儲(chǔ)節(jié)點(diǎn)的時(shí)候,sql執(zhí)行的鎖的范圍比所需單節(jié)點(diǎn)sql
的大,所以盡量編寫查詢單節(jié)點(diǎn)的sql
,一般就是select ...from where ......for update
select into outfile
select use/ignore index
STRAIGHT_JOIN和 NATURAL JOIN
錯(cuò)誤
SELECT t.user_id FROM db1.travelrecord t GROUP BY id;
Expression 't.user_id' is not being grouped
修改成
SELECT any_value(t.user_id) FROM db1.travelrecord t GROUP BY id;
projectItem
被group by
的引用的無聚合函數(shù)的字段需要使用any_value
order by
必須引用select item
中存在的字段
子查詢需要帶有別名
project Item
不支持相同的字段名
limit
,offset
不能超過2147483647
且大于等于0
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: