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
  • 730,956
  • 141
  • 904
  • 1,278
Deb
  • 499
  • 2
  • 15
  • https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS –  Dec 16 '20 at 17:17

1 Answers1

2

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
  • 136,190
  • 20
  • 167
  • 294