查询结果mysql set语句_mysql 将select查询的值赋给update set语句中

表tenant_oper结构:

create table `tenant_oper` (

`id` int(11) not null auto_increment,

`oper_name` varchar(255) not null,

`oper_code` varchar(255) not null,

`remark` varchar(512) default "",

`menu_id` int default 0,

primary key (`id`)

) engine=InnoDB default charset=utf8;

表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;

sql语句:

update tenant_oper set oper_code = '5_4_1_1', menu_id = (select id from tenant_menu where menu_code = '5_4_1') where oper_code = '5_4_1';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值