Skip to content
Advertisement

SQL SELECT cannot reference “INDEX” column

Using Advantage SQL, I have the following query:

This returns this data set:

What I want to do is work with the data in the INDEX column. But if I run a normal SELECT query with this field name:

it doesn’t run. I also cannot add it as an alias or anything.

Are there any workarounds to pull the specific column into a SELECT? My goal is to do text manipulation to remove the quote marks and extract only the pure number that sits in the middle.

This is the first time I’ve had this issue – I’m guessing the word INDEX is somehow a function name which screws things up. But I also am guessing there is a way around it?

Thanks.

Advertisement

Answer

INDEX is a SQL keyword — and probably reserved, which is the problem.

You need to escape it. I believe Advantage supports both double quotes and square braces:

Note that capitalization is important in some databases (but not Advantage SQL) when you escape column names.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement