I was browsing on MySQL Documentation about the update. See UPDATE Syntax. I found out that the syntax is
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
When I executed this statement
UPDATE SampleTB
SET NAME = '123' AND Address = '456'
WHERE ID = 1;
See Here for SQL Fiddle Demonstration Link
The query executed successfully and the value of Name was 0. I was expecting a syntax error on the query.
Can somebody explain to me why it didn’t generate an error? And why was the new value of the column is zero and not 123?
is parsed to something like:
which is one comparison and boolean
ANDof a string and boolean operands.So it takes the current row’s
Addresscolumn value, compares it to a'456'string and result of the comparison is used as a second operand forANDlike'123' AND false