让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Amount int -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(10); mysql> insert into DemoTable values(20); mysql> insert into DemoTable values(30); mysql> insert into DemoTable values(40);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+--------+ | Amount | +--------+ | 10 | | 20 | | 30 | | 40 | +--------+ 4 rows in set (0.00 sec)
以下是查询以降序选择第一行以外的行-
mysql> select *from DemoTable WHERE Amount NOT IN (SELECT MAX(Amount) from DemoTable) ORDER BY Amount DESC;
输出结果
+--------+ | Amount | +--------+ | 30 | | 20 | | 10 | +--------+ 3 rows in set (0.05 sec)