To solve the issue of a single subquery returning multiple rows, you can use the LIMIT clause to limit the subquery result to one row. Here's the updated query:

UPDATE sysmn.昊泽对接_职员 sh
SET sh.职称 = (
    SELECT group_id
    FROM sysmn.sys_group
    WHERE del_flag = '0' AND sh.职称 = group_name
    LIMIT 1
)

By using LIMIT 1, the subquery will only return the first row that satisfies the condition, preventing the error caused by multiple rows being returned.

update sysmn昊泽对接_职员 sh set sh职称 = select group_id from sysmnsys_group where del_flag = 0 and sh职称 = group_name 解决单个子查询返回多个行

原文地址: https://www.cveoy.top/t/topic/iHFz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录