Why doesn't MySQL throw an error when AND keywords are used in an UPDATE SET

时间:2017-04-10 01:21:03

标签: mysql syntax-error mysql-error-1064

The incorrect syntax (first query) does not appear to throw an error in MySQL even though it's clearly wrong. Why is this?

This is the incorrect syntax

UPDATE 
    ATable
SET
    AColumn = '' AND
    BColumn = '' AND
    CColumn = ''
WHERE
    IDColumn = '';

This is the correct syntax

UPDATE 
    ATable
SET
    AColumn = '',
    BColumn = '',
    CColumn = ''
WHERE
    IDColumn = '';

1 个答案:

答案 0 :(得分:3)

UPDATE Statement not generating syntax error when using AND instead of COMMA

this exact question was answered there.

SET NAME = '123' AND Address = '456'

is parsed to something like:

SET NAME = ('123' AND (Address = '456'))

which is one comparison and boolean AND of a string and boolean operands.