订购没有标识符的MySQL结果?
要订购没有标识符的MySQL结果,语法如下-
select * from yourTableName order by 1 DESC LIMIT yourLimitValue;
让我们首先创建一个表-
mysql> create table DemoTable1325 -> ( -> Id int, -> Name varchar(20) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1325 values(100,'Chris'); mysql> insert into DemoTable1325 values(101,'Bob'); mysql> insert into DemoTable1325 values(120,'David'); mysql> insert into DemoTable1325 values(115,'Sam'); mysql> insert into DemoTable1325 values(130,'Carol'); mysql> insert into DemoTable1325 values(150,'Mike');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1325;
这将产生以下输出-
+------+-------+ | Id | Name | +------+-------+ | 100 | Chris | | 101 | Bob | | 120 | David | | 115 | Sam | | 130 | Carol | | 150 | Mike | +------+-------+ 6 rows in set (0.00 sec)
这是查询不带标识符的MySQL结果的查询-
mysql> select * from DemoTable1325 order by 1 DESC LIMIT 4;
这将产生以下输出
+------+-------+ | Id | Name | +------+-------+ | 150 | Mike | | 130 | Carol | | 120 | David | | 115 | Sam | +------+-------+ 4 rows in set (0.00 sec)