Reputation: 493
I had written some wrong syntax for an SQL query. But still, it outputted no error with a java tomcat server. Running on Debian 9. MySQL Version:
mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64)
The query was as follows, I had misplaced the comma ',' with 'and' after the set operator
UPDATE table_pod_print set print_status = 1 and operator_id = 2091 where id = 1
I tried running it on the console, which gave me the following output:
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
Please help me in understanding why the query worked in the first place.
Upvotes: 3
Views: 267
Reputation: 44952
In MySQL SELECT 1 AND 0;
produces 0
because the AND operator evaluates operands as a logical AND. Looking at your query the SET print_status
was evaluated as (adding additional brackets for clarity):
print_status = (1 AND (operator_id = 2091))
which mean it would be 1 AND 1
if operator_id = 2091
for updated id = 1
row was true and 1 AND 0
if not.
Upvotes: 1