[英]phymyadmin add row number in query result
Hi i have this sql code i want to query in phpmyadmin 嗨,我有这个SQL代码,我想在phpmyadmin中查询
SELECT DISTINCT `unit`,`location` FROM `myasset` ORDER BY `unit` asc
It is possible to add custom number in my sql result 可以在SQL结果中添加自定义编号
I tried something like below..its not working ..i received message row_number function does not exist 我尝试了以下内容..它不起作用..我收到消息row_number函数不存在
SELECT DISTINCT Row_Number(),`unit`,`location` FROM `myasset` ORDER BY `unit`
SELECT Row_Number() DISTINCT`unit`,`location` FROM `myasset` ORDER BY `unit`
你可以做
select @rownum:=@rownum+1 No,DISTINCT unit,location FROM myasset ORDER BY unit, (SELECT @rownum:=0);
First you have to set a value like 首先,您必须设置一个值
SET @rnum = 0; SET @rnum = 0;
then 然后
SELECT @rnum:=@rnum+1 AS row_num, DISTINCT unit
, location
FROM myasset
ORDER BY unit
asc SELECT @rnum:= @ rnum + 1 AS row_num,DISTINCT
unit
, location
myasset
ORDER BY unit
asc
Hope it will solve your issue. 希望它能解决您的问题。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.