Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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
按重要性和id对mysql进行排序_Mysql_Sorting - Fatal编程技术网

按重要性和id对mysql进行排序

按重要性和id对mysql进行排序,mysql,sorting,Mysql,Sorting,如何首先按id排序,而不是按“重要”排序。重要列是布尔值,1或零 我试过的 select * from list ORDER BY `id` DESC, `important` DESC; select * from list ORDER BY `id` DESC, `important` DESC; 这没有意义,特别是如果“ID”列是自动递增的。。。它将始终按ID的相反顺序排列。如果您首先想要所有重要的项目,请将您的订单交换到 order by `important`

如何首先按id排序,而不是按“重要”排序。重要列是布尔值,1或零

我试过的

    select * from list ORDER BY `id` DESC, `important` DESC;
    select * from list ORDER BY `id` DESC, `important` DESC;

这没有意义,特别是如果“ID”列是自动递增的。。。它将始终按ID的相反顺序排列。如果您首先想要所有重要的项目,请将您的订单交换到

order by
   `important` desc,
   `id` desc

这将把你列出的所有“重要”项目放在所有“不重要”项目之前。。。然后,在所有重要字段中,将在顶部显示最新的ID,返回到最旧的ID,这没有意义,特别是如果“ID”列是自动递增的。。。它将始终按ID的相反顺序排列。如果您首先想要所有重要的项目,请将您的订单交换到

order by
   `important` desc,
   `id` desc

这将把你列出的所有“重要”项目放在所有“不重要”项目之前。。。然后,在所有重要的ID中,将在顶部显示最新的ID,并返回到您正确操作的最旧ID。您的查询没有错误。您的语法是正确的。你能把你面临的错误写出来吗?你做得对。您的查询没有错误。您的语法是正确的。你能公布你面临的错误吗?