您的位置:首页 > 博客中心 > 数据库 >

MySQL与SqlServer中update操作同一个表问题

时间:2022-03-10 17:57

一 SqlServer中操作如下图

gxlsystem.com,布布扣

这个是没问题的。

二 MySQL中操作如下图

但是在MySQL中想实现这个功能如下图,但是出错了。

gxlsystem.com,布布扣

原来是MySQL中不支持子查询的

我们可以这样修改一下就可以实现它

gxlsystem.com,布布扣

看到没有,我仅仅在查询外面加了一层而已,却实现了。

代码如下:

create PROCEDURE testp(in _id int)
begin
  -- set @tt=(select id from usera where id>_id );
 update  usera set `names`=‘woaini‘ where id in(select t.id from (select s.id from usera s where s.id>_id )t);
end 
call testp(2)

DROP PROCEDURE testp

select  * from  usera

MySQL与SqlServer的区别,需要慢慢发现。

 

MySQL与SqlServer中update操作同一个表问题,布布扣,bubuko.com

热门排行

今日推荐

热门手游