Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save purezhi/4712dce262cf2405203a37e9bbfaf80e to your computer and use it in GitHub Desktop.
Save purezhi/4712dce262cf2405203a37e9bbfaf80e to your computer and use it in GitHub Desktop.
MySQL: 为查询结果自动编号
-- 1、为查询结果自动编号:
select
(@rowNO := @rowNo+1) AS rowno,
user_name
from (
select
wu.screen_name as user_name
from base_wb_ids_pr_hobbies mt
left join base_wb_user wu
on mt.uid = wu.id
where mt.hobby_id = 224424
order by -mt.pagerank
limit 1000
) a, (select @rowNO :=0) b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment