Home > Blockchain >  postgreSQL when to use parentheses for keywords, ON vs USING( )
postgreSQL when to use parentheses for keywords, ON vs USING( )

Time:07-23

I've noticed that it appears arbitrary (to me) when keywords will require a following parentheses. If a table is JOINed by identically named columns, you use USING(ID). The alternative is ON table1.column = table2.column.

Why and when are parentheses required?

CodePudding user response:

USING() can be applied on a list of columns - like in USING(id,seq). The comma, without the parentheses, could be the introduction of a following clause, so the parser can only safely determine the comma between id and seq as a list separator when we put the list into parentheses.

ON, on the other side, is always followed by a Boolean expression, which is straightforward to parse: expression - comparison operator - expression .

  • Related