在MYSQL中运行 select ROWNUM i from (select (@mycnt:=@mycnt + 1) as ROWNUM, DeviceId from dev_info_table order by DeviceId) as A where DeviceId ='123456' 结果是什么
drop procedure if exists rownumber; create procedure rownumber( IN did varchar(255) , OUT mypos int ) Begin declare mycnt int; set @mycnt=0; select ROWNUM into mypos from (select (@mycnt:=@mycnt + 1) as ROWNUM, DeviceId from dev_info_table order by DeviceId) as A where DeviceId =@did; End 其中,did是设备号,mypos是该设备号对应记录的行号。这个存储过程创建成功,但是在如下调用方式中返回结果为空:
where DeviceId =did
DID、did是一样的,传入的值
select ROWNUM i
from (select (@mycnt:=@mycnt + 1) as ROWNUM, DeviceId from dev_info_table order by DeviceId) as A
where DeviceId ='123456'
结果是什么
create procedure rownumber( IN did varchar(255) , OUT mypos int )
Begin
declare mycnt int;
set @mycnt=0;
select ROWNUM into mypos
from (select (@mycnt:=@mycnt + 1) as ROWNUM, DeviceId from dev_info_table order by DeviceId) as A
where DeviceId =@did;
End
其中,did是设备号,mypos是该设备号对应记录的行号。这个存储过程创建成功,但是在如下调用方式中返回结果为空: