MySQL update select 结果

微言记

关注

阅读 167

2022-07-12


需要用到​​INNER JOIN​​。

UPDATE `table_live` a
INNER JOIN (
SELECT
GROUP_CONCAT(c.id) AS group_ids,
ingroup
FROM
`table_live` c
WHERE
ingroup = 11245
) AS b ON a.id = b.ingroup
SET a.groupliveids = b.group_ids
WHERE
a.id = 11245;

参考:https://dev.mysql.com/doc/refman/8.0/en/update.html


相关推荐

精彩评论(0)

0 0 举报