AThena single vs. double quotes

0

Why does this query fail in Athena:

`SELECT COUNT (title) FROM "s3_library_data" WHERE s3_library_data.genre = "Science Fiction"`

but this one works?

`SELECT COUNT (title) FROM "s3_library_data" WHERE s3_library_data.genre = 'Science Fiction'`
AWS
질문됨 2달 전275회 조회
1개 답변
0
수락된 답변

The single and double quote are used for different things.

  • Single quotes are used to denote string literals. For example, if you want to search for a specific string value in a column, you would enclose the string in single quotes, like 'search string'.

  • Double quotes are used to escape reserved keywords that are being used as column or table names.

In your first query you are looking for a literal value - Science Fiction. So you should use single quotes, not double quotes.

AWS
답변함 2달 전
profile picture
전문가
검토됨 2달 전
  • Thank you! My issue is the query is being generated by an LLM and I have been trying to "prompt it to use single quotes.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인