# Table "Key" causing issues with generated query

**URL:** <https://discourse.cakephp.org/t/table-key-causing-issues-with-generated-query/8885>\
**Category:** Need Help\
**Tags:** help\
**Created:** [January 18, 2021, 5:55pm UTC](https://discourse.cakephp.org/t/table-key-causing-issues-with-generated-query/8885 "2021-01-18T17:55:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyhuang](https://avatars.discourse-cdn.com/v4/letter/x/e9c0ed/32.png) [@xyhuang](https://discourse.cakephp.org/u/xyhuang)\
**Post date:** [January 18, 2021, 5:55pm UTC](https://discourse.cakephp.org/t/table-key-causing-issues-with-generated-query/8885/1 "2021-01-18T17:55:34Z")

</div>

Hi all!

I recently performed ./bin/cake bake all keys.  
When I attempted to open the https://…//keys/index.php file the error bellow was generated:

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/9/90951caa2f641d3b3be7c00c4e30ffbb7d733a3e.png)

On the other hand, the following query can be successfully queried from the database:  
SELECT `keys`.`code`, `users`.`id` FROM `keys` LEFT JOIN `users` ON `users`.`id` = (`keys`.`user_id`)

I suspect that because “key” is a special term in mysql, it is causing issues within the statement.  
Is there a way to go around this issue without renaming the table since “keys” are exactly what we are trying to manage?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [January 18, 2021, 9:40pm UTC](https://discourse.cakephp.org/t/table-key-causing-issues-with-generated-query/8885/2 "2021-01-18T21:40:36Z")

</div>

You can enable [identifier quoting](https://book.cakephp.org/3/en/orm/database-basics.html#identifier-quoting), but as noted there are performance drawbacks to doing so. It would at least be a good thing to try to make sure that this is in fact the source of the problem.

---

<div class="post-metadata">

**Author:** ![xyhuang](https://avatars.discourse-cdn.com/v4/letter/x/e9c0ed/32.png) [@xyhuang](https://discourse.cakephp.org/u/xyhuang)\
**Post date:** [January 19, 2021, 3:24pm UTC](https://discourse.cakephp.org/t/table-key-causing-issues-with-generated-query/8885/3 "2021-01-19T15:24:56Z")

</div>

Thank you, I think that’s the case because, without quoting the keyword keys these errors are produced:

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/f/f845c0cafc4f41642070f1c0b80fb4bf7751d612.png)

Meanwhile, by quoting the first “keys” the error at position 7 disappeared.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/4/4f6e6b203d4c0d6501c7e4641f9c964edc9c3bd7.png)
