Question

How to use an SQL reserved keyword like the column name "desc" in a select statement?

select "desc" from tablename
Was it helpful?

Solution

Use brackets

select [desc] from tablename

OTHER TIPS

According to Standard, you can use delimited identifiers in this case, ex.

create table Tdesc("desc" int);
go
select "desc" from Tdesc order by "desc" desc;

back quotes worked for me in Hive SQL: I have a column named from, so:

select `from` from myTable;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top