TiDBTiDB Docs Dash 2024

Jan 9 - Jan 12 (UTC)
Join us to improve docs and win a prize!
Sign InTry Free

Expression Syntax

An expression is a combination of one or more values, operators, or functions. In TiDB, expressions are mainly used in various clauses of the SELECT statement, including Group by clause, Where clause, Having clause, Join condition and window function. In addition, some DDL statements also use expressions, such as the setting of the default values, columns, and partition rules when creating tables.

The expressions can be divided into the following types:

The following rules are the expression syntax, which is based on the parser.y rules of TiDB parser. For the navigable version of the following syntax diagram, refer to TiDB SQL Syntax Diagram.

Expression
singleAtIdentifierassignmentEqNOTExpressionlogOrXORlogAndExpressionMATCH(ColumnNameList)AGAINST(BitExprFulltextSearchModifierOpt)PredicateExprIsOrNotOpNULLCompareOpsingleAtIdentifierassignmentEqPredicateExprAnyOrAllSubSelectIsOrNotOptrueKwdfalseKwdUNKNOWN
PredicateExpr
BitExprBetweenOrNotOpBitExprANDBitExprInOrNotOp(ExpressionList)SubSelectLikeOrNotOpSimpleExprLikeEscapeOptRegexpOrNotOpSimpleExpr
BitExpr
BitExpr|&<<>>*/%DIVMOD^BitExpr+-BitExprINTERVALExpressionTimeUnitSimpleExpr
SimpleExpr
SimpleIdent->->>stringLitFunctionCallKeywordFunctionCallNonKeywordFunctionCallGenericSimpleExprCOLLATECollationNamepipesSimpleExprWindowFuncCallLiteralparamMarkerVariableSumExpr!~-+NOTBINARYSimpleExprEXISTSSubSelect(ExpressionList,ROW(ExpressionList,ExpressionbuiltinCast(ExpressionASCastTypeDEFAULTVALUES(SimpleIdentCONVERT(Expression,CastTypeUSINGCharsetName)CASEExpressionOptWhenClauseElseOptEND

Was this page helpful?

Download PDFRequest docs changesAsk questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.