UPDATE sys_menu SET menu_name = '管加工厂' WHERE menu_id = 3381;

SET @pid = (SELECT menu_id FROM sys_menu WHERE menu_name = '管加工厂' LIMIT 1);

INSERT INTO sys_menu(menu_name, parent_id, path, perms, create_by, create_time, remark) VALUE ('生产填报', @pid, '$2/Work/YAOA/productionAndLineReport', 'productionAndLineReport', 'admin', NOW(), '生产上报');

SET @id = (SELECT menu_id FROM sys_menu WHERE menu_name = '生产填报');

UPDATE sys_menu SET parent_id = @id WHERE menu_name = '原料月报';
UPDATE sys_menu SET parent_id = @id WHERE menu_name = '生产日报';
UPDATE sys_menu SET parent_id = @id WHERE menu_name = '质检日报';
UPDATE sys_menu SET parent_id = @id WHERE menu_name = '质检月报';

# 下面是练习


UPDATE sys_menu AS sm1
    JOIN (
        SELECT menu_id
        FROM sys_menu
        WHERE menu_name = '生产填报'
    ) AS sm2 ON sm1.menu_name = '原料月报'
SET sm1.parent_id = sm2.menu_id WHERE sm1.menu_name = '原料月报';


SELECT sm1.father_id, sm2.parent_id, sm2.menu_name, sm2.menu_id
FROM
    (SELECT menu_id as father_id FROM sys_menu WHERE menu_name = '生产填报') AS sm1
        INNER JOIN
    (SELECT menu_id, parent_id, menu_name FROM sys_menu WHERE menu_name = '原料月报') AS sm2
