在选择查询中显示行号 [英] show row number in select query

查看:49
本文介绍了在选择查询中显示行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此查询有什么问题?它在rowno列中显示为空.

what is the problem with this query? it shows null in rowno column.

SELECT @rowno:=@rowno+1 `rn`,`id`, `title`, `topic` 
FROM stories,(SELECT @rownum:=0) r 
WHERE newstype='2';

我在"MySQL查询浏览器"中运行它

i run it in 'MySQL Query browser'

提前谢谢.

推荐答案

以递增方式使用rowno,但在初始分配中使用rownum

In the increment you are using rowno but in the initial assignment you are using rownum

这篇关于在选择查询中显示行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆