Home > Software design >  MySql reserved word in select with alias table name
MySql reserved word in select with alias table name

Time:06-22

I've read the other MySQL reserved words questions that suggest using backticks when calling reserved words in MySQL.

Unfortunately, I've tried those and they haven't worked in my particular case where multiple tables/table aliases are being used. My query looks like:

select rf.id, `s.Status` as 'Status'
from form rf 
left outer join sharerequest rr on rr.formId = rf.id
left outer join schedule s on s.sharerequestid = rr.id

I've tried different variations of this (backticks around just the word "status", encapsulating it in brackets (like SQLServer)) and nothing has worked.

I'm pretty sure backticks are how I'm supposed to handle this but I'm not sure what I'm doing wrong here.

CodePudding user response:

For the record, this is covered in the MySQL manual here:

https://dev.mysql.com/doc/refman/8.0/en/identifier-qualifiers.html

If any components of a multiple-part name require quoting, quote them individually rather than quoting the name as a whole. For example, write `my-table`.`my-column`, not `my-table.my-column`.

  • Related