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貌似没办法执行多条语句 所以看看就可以了

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-06-12
  • 2022-01-11
  • 2022-01-21
  • 2021-07-13
  • 2021-09-27
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
相关资源
相似解决方案