mysql select自增变量(包括读取当前第几行)
SET @rownum =0;
select id,@rownum := @rownum +1 as i from ceshi order by dd desc,id desc;
变量是直接输出在结果集的
SET @rownum =0;
@rownum :=1
这2个个是变量赋值的方式
SET @rownum =0;
select i from
(select id,dd,@rownum := @rownum +1 as i from ceshi order by dd desc,id desc) as cc where id=4;
这个查询用户第几名的
不过mysql貌似没办法执行多条语句 所以看看就可以了
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/4060.html