0
column1 = value     WHERE cond='1'
column2 = value     WHERE cond='2'

在上面的例子中。这是在mysql中编码的正确方法吗

UPDATE table SET (column1='value' WHERE cond='1') OR (column2='value' WHERE cond='2')
4

1 回答 1

1
UPDATE
   table
SET
   column1 = (CASE cond WHEN '1' THEN 'value' ELSE column1 END)
 , column2 = (CASE cond WHEN '2' THEN 'value' ELSE column2 END)
WHERE
  cond IN ('1', '2')
;
于 2013-07-02T03:04:50.250 回答