Is it valid syntax to have a column name prefixed with a number, e.g., 3name?

43 views Asked by At

screenshot of queries

While toiling on a report last friday, I noticed a column that returned "3" for every row even though the data in the table said otherwise. After squinting very hard at my sql, I noticed a typo in my select list that was causing the problem.

Why does the sql parser allow the sytax below? I would have thought that this would return an error, since the column "3Name" does not exist in the table.

Select 3Name from Employee
1

There are 1 answers

0
Jerry On BEST ANSWER

It is interpreted as SELECT 3 AS NAME and hence the result with Column 'Name' And value 3 for all the rows.