I was recently assigned a task of creating an auction system. During my work, I met numerous occasions where my SQL queries that contained joins failed to execute due to amb
I've faced with MySQLSyntaxErrorException
:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank
after executing the following query:
insert into my_table (rank) values (1);
Because rank
column name clashes with sql keyword rank
.
SOLUTION:
I've added back quotes to rank
column name and problem was solved:
insert into my_table (`rank`) values (1);
Another way to solve the problem is to use table name instead of back quotes:
insert into my_table (my_table.rank) values (1);