我有一张桌子,叫做 Level。
id | level | points(minimum)
-------------------------
1 | 1 | 0
2 | 2 | 100
3 | 3 | 200
假设我有 189 分,我如何检查用户在哪个级别?
编辑:
选择了最佳答案。现在我通过在 SELECT 查询之前添加 EXPLAIN 来比较请求,我得到了这个结果:
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
-------------------------------------------------------------------------------------------------------------
1 | SIMPLE | level | ALL | NULL | NULL | NULL | NULL | 8 | Using where
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
-------------------------------------------------------------------------------------------------------------
1 | SIMPLE | level | ALL | NULL | NULL | NULL | NULL | 8 | Using where; Using filesort
我怎么知道哪个更好或更快?