mysql 中将select查询的值赋给insert语句

表tenant_menu的结构:
create table `tenant_menu` (
  `id` int(11) not null auto_increment, 
  `menu_code` varchar(255) not null,
  `menu_name` varchar(255) not null,
  `menu_position` smallint not null,
  `menu_url` varchar(255) default "",
  `parent_id` int default 0,
  primary key (`id`)
) engine=InnoDB default charset=utf8;
insert into tenant_menu(menu_name, menu_code, parent_id, menu_url, menu_position) select '推广会员列表', '5_4_1', id, '/user/promotion', '1' from tenant_menu where menu_code = '5_4';

你可能感兴趣的:(mysql)