IF EXISTS (SELECT * FROM table1 WHERE group_id='8')
UPDATE table2 SET (...)
WHERE usertype='numbereight'
我究竟做错了什么?我需要根据 group_id 更新用户类型
IF EXISTS (SELECT * FROM table1 WHERE group_id='8')
UPDATE table2 SET (...)
WHERE usertype='numbereight'
我究竟做错了什么?我需要根据 group_id 更新用户类型
试试这个:
UPDATE table2
SET someColumn = 'somevalue'
WHERE EXISTS(SELECT * FROM table1 WHERE group_id='8')
AND usertype='numbereight'
你可以尝试这样的事情:
UPDATE table2
SET (...)
WHERE usertype='number eight' AND EXIST(SELECT * FROM table1 WHERE group_id='8');
尝试
UPDATE table2
SET (...)
WHERE usertype = 'numbereight'
AND exists (select * from table1 where group_id = '8')
您可以加入表格并更新您需要的任何字段
UPDATE t1 JOIN t2 ON t1.id = t2.id
SET
t2.field = 'whatever'
WHERE
t1.group_id= '8' AND
t2.usertype = 'numbereight'