经过验证 SQL语句中的between 范围1 and 范伟2
语句是包括的范围1和范围2的
Oracle代码
SQL> create table test
2(
3test1 number(2)
4);
表已创建。
SQL> insert into test values(1);
已创建 1行。
SQL> insert into test values(2);
已创建 1行。
SQL> insert into test values(10);
已创建 1行。
SQL> commit;
提交完成。
SQL> select * from test where test1 between 1and10;
TEST1
----------
1
2
10
SQL> create table test 2 ( 3 test1 number(2) 4 );表已创建。SQL> insert into test values(1);已创建 1 行。SQL> insert into test values(2);已创建 1 行。SQL> insert into test values(10);已创建 1 行。SQL> commit;提交完成。SQL> select * from test where test1 between 1 and 10; TEST1---------- 1 2 10
Mysql代码
mysql> use mldn
Database changed
mysql> create table test
-> (
-> test1 int
-> );
Query OK, 0rows affected (0.69sec)
mysql> insert into test values(1);
Query OK, 1row affected (0.10sec)
mysql> insert into test values(2);
Query OK, 1row affected (0.00sec)
mysql> insert into test values(10);
Query OK, 1row affected (0.00sec)
[size=xx-large]观察此处:[/size]
mysql> select * from test where test1 between 1and10;
+-------+
| test1 |
+-------+
| 1|
| 2|
| 10|
+-------+
3rows in set (0.07sec)
mysql> alter table test modify test1 varchar(10);
Query OK, 3rows affected (0.27sec)
Records: 3Duplicates:0Warnings:0
mysql> insert into test values('a');
Query OK, 1row affected (0.04sec)
mysql> insert into test values('d');
Query OK, 1row affected (0.02sec)
mysql> insert into test values('z');
Query OK, 1row affected (0.02sec)
mysql> commit;
Query OK, 0rows affected (0.00sec)
[size=xx-large]观察此处:[/size]
mysql> select * from test where test1 between 'a'and'z';
+-------+
| test1 |
+-------+
| a |
| d |
| z |
+-------+
3rows in set (0.02sec)
mysql> use mldnDatabase changedmysql> create table test -> ( -> test1 int -> );Query OK, 0 rows affected (0.69 sec)mysql> insert into test values(1);Query OK, 1 row affected (0.10 sec)mysql> insert into test values(2);Query OK, 1 row affected (0.00 sec)mysql> insert into test values(10);Query OK, 1 row affected (0.00 sec)[size=xx-large]观察此处:[/size]mysql> select * from test where test1 between 1 and 10;+-------+| test1 |+-------+| 1 || 2 || 10 |+-------+3 rows in set (0.07 sec)mysql> alter table test modify test1 varchar(10);Query OK, 3 rows affected (0.27 sec)Records: 3 Duplicates: 0 Warnings: 0mysql> insert into test values('a');Query OK, 1 row affected (0.04 sec)mysql> insert into test values('d');Query OK, 1 row affected (0.02 sec)mysql> insert into test values('z');Query OK, 1 row affected (0.02 sec)mysql> commit;Query OK, 0 rows affected (0.00 sec)[size=xx-large]观察此处:[/size]mysql> select * from test where test1 between 'a' and 'z';+-------+| test1 |+-------+| a || d || z |+-------+3 rows in set (0.02 sec)