0

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.

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
Deb
  • 429
  • 2
  • 9

1 Answers1

1

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.

Gregor Thomas
  • 119,032
  • 17
  • 152
  • 277