1

I have a table A with some columns in Sybase IQ. One of the columns is named "Comment".

Whenever I select that column:

select Comment from A

I got the error:

[Error Code: 102, SQL State: 42W04]  SQL Anywhere Error -131: Syntax error near 'Comment'

I am able to select other columns without issues. Could you advise the reason and solution? Thank you

hydradon
  • 1,316
  • 1
  • 21
  • 52
  • 3
    If ever you encounter a situation where one name seems to be treated differently from others that otherwise seem identical, your first instinct should always be to search for the [reserved words in whatever language you're using](http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1510/html/iqrefbb/Alhakeywords.htm) – Damien_The_Unbeliever Jul 26 '17 at 08:27

1 Answers1

2

Try

select "Comment" from A

COMMENT is a reserved word in Sybase IQ.

Here is the link explaining your problem.

Some keywords in SQL are also reserved words. To use a reserved word in a SQL statement as an identifier, you must enclose the word in double quotes. Many, but not all, of the keywords that appear in SQL statements are reserved words. For example, you must use the following syntax to retrieve the contents of a table named SELECT.

SELECT * FROM "SELECT"

Vojtěch Dohnal
  • 7,867
  • 3
  • 43
  • 105