I am using CakePHP to create an online education system. I am getting this error: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: ‘Users’ when I try to get a list of users from my database. I am using the code created by bake, with no modifications. I am not sure what is happening. The query that is created is: SELECT Users.users_id AS Users__users_id, Users.users_username AS Users__users_username, Users.users_password AS Users__users_password, Users.users_hint AS Users__users_hint, Users.users_answer AS Users__users_answer, Users.users_grades AS Users__users_grades FROM users Users INNER JOIN users Users ON Users.users_id = (Users.users_id) LIMIT 20 OFFSET 0.
Any help would be greatly appreciated.
Thank you, Troy L. Marker
It would help showing your table and fields. Ther error is from INNER JOIN users Users ON Users.users_id = (Users.users_id) it seems. You need to provide different aliases.
Thanks for the response. I’m sorry about the lack of information. I will put something together, but my next question is how can I change the query? As I mentioned, I am using the code that bake created for me.
After working with it a little more, I got it to work. My mistake was assuming that the code created by Bake was ready to go, I did not think I would have to tweak it, but after doing just that, it is working. I do appreciate your help, it got me going in the right direction.