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
posta 2 mesi fa275 visualizzazioni
1 Risposta
0
Risposta accettata

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
con risposta 2 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa
  • 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.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande