mysql> (select "yes" from dual where 5 between 1 and 10) union (select "no") limit 1;
+-----+
| yes |
+-----+
| yes |
+-----+
1 row in set (0.02 sec)
mysql> (select "yes" from dual where 5 between 10 and 1) union (select "no") limit 1;
+-----+
| yes |
+-----+
| no |
+-----+
1 row in set (0.00 sec)
以前一直没问题原来是运气好 ..
+-----+
| yes |
+-----+
| yes |
+-----+
1 row in set (0.02 sec)
mysql> (select "yes" from dual where 5 between 10 and 1) union (select "no") limit 1;
+-----+
| yes |
+-----+
| no |
+-----+
1 row in set (0.00 sec)
以前一直没问题原来是运气好 ..
本文通过两个具体的 SQL 查询案例,展示了 MySQL 中 BETWEEN 运算符的使用方法及其返回结果的变化。通过对不同条件下的查询结果对比,帮助读者理解 BETWEEN 的工作原理及注意事项。
10万+

被折叠的 条评论
为什么被折叠?



