i have article table
`id`, `article_id`, `stage_1_point`, `stage_2_point` i need top 10 articles based on
(stage_1_point+stage_2_point), in list , when view article need show place. question how can show place without using order by.
use order (stage_1_point+stage_2_point) desc
so, like
select `id`, `article_id`, `stage_1_point`, `stage_2_point` your_table order (stage_1_point+stage_2_point) desc limit 0,10 update
as op stated, he/she needs know position of specific article.
select * (select `id`, `article_id`, `stage_1_point`, `stage_2_point`, @currank := @currank + 1 rank your_table, (select @currank := 0) r order (stage_1_point+stage_2_point) desc) tab `article_id`=10 above query return rows article_id 10, have column rank tells position of article.
Comments
Post a Comment