row_number() ) r, test_table t 解释:给test_table里的数据设置行号, rn是行号 row_number() over(partition by) ,@rank:=) as rank,t.*,@uid:=t.user_id,@cid:=t.city_id ) r, (select user_id,city_id,city_name,id from t_user_city order by user_id,city_id,id) t; ; set @CI:=n…