Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mysql选择查询_Php_Mysql - Fatal编程技术网

Php mysql选择查询

Php mysql选择查询,php,mysql,Php,Mysql,我有这个mysql表,我想选择最后10条记录,这就是我的代码 3717 8 2012-03-30 16:34:17 3718 10 2012-03-30 16:34:22 3719 9 2012-03-30 16:34:27 3720 6 2012-03-30 16:34:32 3721 7 2012-03-30 16:34:37 3722 8 2012-03-30 16:34:42

我有这个mysql表,我想选择最后10条记录,这就是我的代码

    3717    8   2012-03-30 16:34:17
    3718    10  2012-03-30 16:34:22
    3719    9   2012-03-30 16:34:27
    3720    6   2012-03-30 16:34:32
    3721    7   2012-03-30 16:34:37
        3722    8   2012-03-30 16:34:42
    3723    10  2012-03-30 16:34:47
    3724    5   2012-03-30 16:34:50
这就是我得到的

SELECT * FROM mach_1 ORDER BY id DESC  LIMIT 10

问题是我如何扭转这种局面

试试这样的做法:

2012-03-30 16:34:50
2012-03-30 16:34:47
2012-03-30 16:34:42
2012-03-30 16:34:37
2012-03-30 16:34:32
2012-03-30 16:34:27
2012-03-30 16:34:22
2012-03-30 16:34:17
2012-03-30 16:34:10
2012-03-30 16:34:05

试着这样做:

2012-03-30 16:34:50
2012-03-30 16:34:47
2012-03-30 16:34:42
2012-03-30 16:34:37
2012-03-30 16:34:32
2012-03-30 16:34:27
2012-03-30 16:34:22
2012-03-30 16:34:17
2012-03-30 16:34:10
2012-03-30 16:34:05

您很可能无法绕过嵌套选择:

select * from (select * from mach_1 order by id desc 
limit 10) as tbl order by tbl.id;

这将首先选择最后10个条目,然后按照您的意愿对它们进行升序排序。

您很可能无法绕过嵌套选择:

select * from (select * from mach_1 order by id desc 
limit 10) as tbl order by tbl.id;

这将首先选择最后10个条目,然后按照您想要的方式对它们进行升序排序。

在这里学习所有内容:但将desc更改为asc使其变得简单:::如果我们有一个表,其中包含1,2,3,4,5,6如果我们从表顺序按id desc limit 3中选择*,我们将得到6,5,4如何在此处反转结果学习所有内容:但将desc更改为为了简单起见:::如果我们有一个1,2,3,4,5,6的表,如果我们从表顺序中按id desc limit 3选择*,我们将得到6,5,4,如何反转结果