Assuming that I have a query as the following
update Object set status=#{statusValue} where attr1=#{par1} or attr2=#{par2};
I would like to know the processing order of the condition in the WHERE clause. I mean, if attr1=#{par1} result TRUE, the value of par2 is checked or is sufficient the first condition?
Thx
MySQL evaluates boolean expressions left to right, and supports short-circuiting like most programming languages do.
In an expression x AND y
, if x
is false, then y
is not evaluated.
In an expression x OR y
, if x
is true, then y
is not evaluated.
You can test this:
SET @y := 0;
SELECT true OR (@y := 42);
SELECT @y;
Should yield 0, because the right side of the expression was not evaluated.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments