SQL命令:

UPDATE table1
SET colOne=1
WHERE id EXISTS (
SELECT IF(col1=19,col2,col1) AS id
FROM table2
WHERE
(col3=19 AND col4='X')
OR
(col3=0 AND col4='Y' AND (col1=19 OR col2=19))
)


内部的SELECT查询可以单独工作

最佳答案

UPDATE table1
SET colOne=1
WHERE id IN (
SELECT IF(col1=19,col2,col1) AS id
FROM table2
WHERE
(col3=19 AND col4='X')
OR
(col3=0 AND col4='Y' AND (col1=19 OR col2=19))
)

关于mysql - 我的SQL代码在哪里出错?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30012701/

10-13 03:19