Escaping Restricted Keywords

Escaping a restricted keyword that has been used as an identifier will allow the object associated with the identifier to be queried as usual.

One way to do this is to ensure the identifier involving a restricted keyword follows a period, because words following periods are always considered as identifiers in MySQL. For example, a query that refers to a table as database_name.begin would run successfully, but a query referring to the table as begin would return an error due to begin being a restricted keyword.

Another method for escaping these keywords is wrapping them in backticks. For example, begin could also be escaped as follows: ’begin’.

Last modified: April 24, 2021

Was this article helpful?