select * from user,(select count(*) count,fans.userid from fans group by fans.userid) fans_count where fans_count.userid = user.id order by fans_count.count