本文介绍了如何更改行计数顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下 MySql 查询,这是从我之前的问题中获得的.
I am having the below MySql Query, which is obtained from my previous question.
SELECT row_count,id FROM
(
SELECT
IF(i.id = @sameIndustryId, @a :=@a + 1, @a := 1) AS row_count,
@sameIndustryId := i.id,
p.*, u.first_name,
u.designation,
u.profile_picture,
i. NAME AS industry,
l.location
FROM
industry i,
projects p,
location l,
user_profile u,
(SELECT @a := 1, @sameIndustryId := 0 ) var
WHERE
u.uid = p.uid
AND p.location_id = l.id
AND i.id = p.industry_id
AND p.abstract != ''
ORDER BY i.id,p.id desc
) t
以上查询提供以下输出;
The above query provides below output;
但我想要按升序排列的row_count.如何在这里实现
But I want that row_count in ascending order.How to achieve here
我的预期输出是这样的(我只是在这里显示了industry_id;row_count是基于此创建的)
My expected output is like (I just showed industry_id here; row_count is created based on this)
推荐答案
Use order by row_count asc
after t
Use order by row_count asc
after t
这篇关于如何更改行计数顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!