hi my name is milind and trying to mysql UPDATE query fire with CASE and WHEN statement and i getting this error below:
24 errors were found during analysis.
Unrecognized keyword. (near "CASE" at position 27)
Unrecognized keyword. (near "WHEN" at position 32)
Unexpected token. (near "id" at position 37)
Unexpected token. (near "=" at position 39)
Unexpected token. (near "'2'" at position 40)
Unrecognized keyword. (near "THEN" at position 44)
Unexpected token. (near "'Y'" at position 49)
Unrecognized keyword. (near "ELSE" at position 53)
Unrecognized keyword. (near "status" at position 58)
Unrecognized keyword. (near "END" at position 65)
Unexpected token. (near "," at position 68)
Unrecognized keyword. (near "status" at position 71)
Unexpected token. (near "!=" at position 78)
Unrecognized keyword. (near "CASE" at position 81)
Unrecognized keyword. (near "WHEN" at position 86)
Unrecognized keyword. (near "status" at position 91)
Unexpected token. (near "=" at position 98)
Unexpected token. (near "'2'" at position 99)
Unrecognized keyword. (near "THEN" at position 103)
Unexpected token. (near "'N'" at position 108)
Unrecognized keyword. (near "ELSE" at position 112)
Unrecognized keyword. (near "status" at position 117)
Unrecognized keyword. (near "END" at position 124)
Unexpected token. (near "," at position 127)
and my UPDETE query is below:
UPDATE quotes SET status = CASE WHEN id='2' THEN 'Y' ELSE status END,
status = CASE WHEN id !='2' THEN 'N' ELSE status END,
WHERE id='2';
i want update where status=Y insted of status=N and where stutus=N insted of status=Y.