sql 获取上一条id
-- 1. 插入主菜单
INSERT INTO `system_menu` 
( `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) 
VALUES 
( '业务重启', '', 2, 4, 5184, 'business-restart', 'ep:refresh', 'daily/businessrestart/index', 0, b'1', b'1', b'1', '1', '2026-05-07 15:15:05', '1', '2026-05-08 08:58:14', b'0');

-- 2. 获取刚才生成的 ID 并存入变量
SET @last_id = LAST_INSERT_ID();

-- 3. 后续 SQL 使用 @last_id 作为 parent_id
INSERT INTO `system_menu` ( `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `status`, `creator`, `create_time`, `updater`, `update_time`) 
VALUES ( '新增', 'daily:business-restart:create', 3, 1, @last_id, '', 0, '1', '2026-05-07 15:15:54', '1', '2026-05-07 16:09:46');

INSERT INTO `system_menu` ( `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `status`, `creator`, `create_time`, `updater`, `update_time`) 
VALUES ( '修改', 'daily:business-restart:update', 3, 2, @last_id, '', 0, '1', '2026-05-07 15:16:07', '1', '2026-05-07 15:16:07');

INSERT INTO `system_menu` ( `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `status`, `creator`, `create_time`, `updater`, `update_time`) 
VALUES ( '删除', 'daily:business-restart:delete', 3, 3, @last_id, '', 0, '1', '2026-05-07 15:16:24', '1', '2026-05-07 15:16:24');

INSERT INTO `system_menu` ( `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `status`, `creator`, `create_time`, `updater`, `update_time`) 
VALUES ( '查询', 'daily:business-restart:query', 3, 4, @last_id, '', 0, '1', '2026-05-07 15:16:37', '1', '2026-05-07 15:16:37');

INSERT INTO `system_menu` ( `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `status`, `creator`, `create_time`, `updater`, `update_time`) 
VALUES ( '导出', 'daily:business-restart:export', 3, 5, @last_id, '', 0, '1', '2026-05-07 15:16:49', '1', '2026-05-07 15:16:49');
暂无评论

发送评论 编辑评论


				
上一篇