当前位置: 代码迷 >> SQL >> SQL话语中between and 范围
  详细解决方案

SQL话语中between and 范围

热度:320   发布时间:2016-05-05 15:12:45.0
SQL语句中between and 范围


经过验证 SQL语句中的between 范围1 and  范伟2 
语句是包括的范围1和范围2的


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> 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)

  相关解决方案