Deb
Deb

Reputation: 539

Select column name containing forward slash in PostgreSQL

I am new to PostgreSQL and trying the below two scenarios:

  1. Select a column name which already has a forward slash(/) in database (Road/Highway)
  2. Using case on same column along with index
Select Road/Highway, 
case 
 when index(upcase(Road/Highway), 'xturn') > 0 then 2
 else 0
end as preferred_road
from abc_data;

But I am getting syntax error near index and for slash it is only taking Road.

Upvotes: 0

Views: 2468

Answers (1)

Gregor Thomas
Gregor Thomas

Reputation: 146030

Generally / means "division", so your column name is non-standard, much like working with keyword column names, column names with special characters must be quoted with double quotes. Use "Road/Highway" when referring to the column.

Upvotes: 2

Related Questions