IF EXISTS (SELECT * FROM table1 WHERE group_id='8')
UPDATE table2 SET (...)
WHERE usertype='numbereight'
我在做错了什么?我需要根据group_id 更新usertype
答案 0 :(得分:1)
请改为尝试:
UPDATE table2
SET someColumn = 'somevalue'
WHERE EXISTS(SELECT * FROM table1 WHERE group_id='8')
AND usertype='numbereight'
答案 1 :(得分:1)
你可以尝试这样的事情:
UPDATE table2
SET (...)
WHERE usertype='number eight' AND EXIST(SELECT * FROM table1 WHERE group_id='8');
答案 2 :(得分:1)
尝试
UPDATE table2
SET (...)
WHERE usertype = 'numbereight'
AND exists (select * from table1 where group_id = '8')
答案 3 :(得分:1)
您可以加入表格并更新所需的任何字段
UPDATE t1 JOIN t2 ON t1.id = t2.id
SET
t2.field = 'whatever'
WHERE
t1.group_id= '8' AND
t2.usertype = 'numbereight'