0

I have a remote connection into a mysql database from Redshift. Mysql table has a column year_month which is a reserved word in mysql and since this table is already populated and applications are using it, column name cannot be changed.

I tried backtick, double quotes - both are failing.

select id, `year_month` from updoc_mysql.apsetup;

5
  • Please provide more information such as table schema Commented Mar 21, 2023 at 13:18
  • RedShift uses doublequotes for identifiers. docs.aws.amazon.com/redshift/latest/dg/r_names.html Apply them then look what query text is received by MySQL (in General Query Log). Maybe you'd use "`year_month`" or even ANSI_QUOTES SQL Mode to be set.. Commented Mar 21, 2023 at 13:36
  • @Akina - I tried "year_month" and I get the error: ERROR: column "year_month" does not exist. I can not set ANSI_QUOTES since I am running my queries as a federated user accessing the remote mysql. Commented Mar 21, 2023 at 15:37
  • Have you tried the syntax which I provide - with both doublequotes and backticks? If none works than enable general log and obtain SQL codes received by MySQL for all syntax variations. and I get the error - NEVER shorten the message error! Provide complete text (add to question text as an update, format as code), from first to last char. Commented Mar 21, 2023 at 16:33
  • @Akina - I tried all combinations of double quotes and backticks and nothing is working. Please remember these are queries run on an external mysql database from redshift. I do not have any access directly in mysql and I have reached out to the concerned person to enable logging and provide me feedback. Nothing has been done so far. I was hoping someone would have got this issue resolved. Commented Mar 23, 2023 at 6:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.