Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
「重要」ではなく、最初に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が表示されます