你可以这样
SELECt tu.id, tr.name, tu.pointsFROM table_ranks as tr LEFT JOIN (SELECt * FROM table_ranks LIMIT 1,69596585953484) as l ON l.points_needed = (SELECt MIN(points_needed) FROM table_ranks WHERe points_needed > tr.points_needed limit 1) LEFT OUTER JOIN table_users AS tu ON tu.points >= tr.points_needed AND tu.points < l.points_neededWHERe tu.id IS NOT NULLgroup by tu.id
小提琴
输出
-------------------------| id | points | name |-------------------------| 1 | lvl0 | 2 || 2 | lvl1 | 10 || 3 | lvl2 | 21 || 4 | lvl2 | 29 |-------------------------



