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
);