so i was wondering why:
SELECT Colunm_Name Column_Name from Table_Name
WITHOUT a comma between column names does not return a syntax error, instead it return records with the first column only. At first i thought the comma was optional, but then i tried:
SELECT Colunm_Name Column_Name Column_Name from Table_Name
and this returns a syntax error near the third column. Any idea why? is there a reason why you could put two column names without a comma even though it omits the second column? Thnx!
Writing a word next to a column is treated as the alias for the selected column. The result for the query will display that alias as the column name. Here, AS
keyword is ommitted. eg
SELECT Column_Name1 AS Column_Name2 FROM EMPLOYEE
is same as
SELECT Column_Name1 Column_Name2 FROM EMPLOYEE
Both, the queries will return the data with one column and the column header will be Column_Name2
Whereas, the third word will be treated as syntax error:
SELECT Column_Name1 Column_Name2 Column_Name3 FROM EMPLOYEE
will return error as it will be expecting a comma or FROM
keyword just after Column_Name2
word.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.