wangming1993 / issues

记录学习中的一些问题,体会与心得 https://wangming1993.github.io/issues
8 stars 4 forks source link

mysql update from select #86

Open wangming1993 opened 6 years ago

wangming1993 commented 6 years ago
update
    groups
set
    groups.wechatId = ?,
    groups.ownerWechatId = ?,
    groups.sid = ?,
    createdAt = ?,
    status = ?
where
    groups.id = ? and
    not exists (
        select g1.sid from (
            select * from groups as g2 where g2.groupSetId = ? and g2.sid= ?
        ) as g1 where g1.id <> groups.id
    );