让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Value int -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(20); mysql> insert into DemoTable values(40); mysql> insert into DemoTable values(30); mysql> insert into DemoTable values(10); mysql> insert into DemoTable values(90); mysql> insert into DemoTable values(70); mysql> insert into DemoTable values(80); mysql> insert into DemoTable values(9); mysql> insert into DemoTable values(8);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable ;
这将产生以下输出-
+-------+ | Value | +-------+ | 20 | | 40 | | 30 | | 10 | | 90 | | 70 | | 80 | | 9 | | 8 | +-------+ 9 rows in set (0.00 sec)
这是将“环绕”到第一个值并在单个查询中实现ORDER BY ASC和DESC的查询-
mysql> select *from DemoTable -> order by Value > 10 desc,Value asc;
这将产生以下输出-
+-------+ | Value | +-------+ | 20 | | 30 | | 40 | | 70 | | 80 | | 90 | | 8 | | 9 | | 10 | +-------+ 9 rows in set (0.00 sec)