ORDER BY ကို result တွေကို အစဉ်လိုက်စီဖို့သုံးပါတယ်။ Report, leaderboard, latest posts, product price sorting တွေမှာ မဖြစ်မနေသုံးရတဲ့ keyword ပါ။
• ASC — ငယ်ရာကကြီးရာ / A က Z သို့ စီရန်
• DESC — ကြီးရာကငယ်ရာ / Z က A သို့ စီရန်
Default က ASC ဖြစ်ပါတယ်။
sql
SELECT CustomerName, Country
FROM Customers
ORDER BY Country ASC, CustomerName ASC;You should see
+--------------------+---------+ | CustomerName | Country | +--------------------+---------+ | Alfreds Futterkiste| Germany | | Ana Trujillo | Mexico | | Antonio Moreno | Mexico | | Around the Horn | UK | +--------------------+---------+ Important things to notice: ပထမဦးဆုံး Country နဲ့စီပြီး country တူရင် CustomerName နဲ့ထပ်စီပါတယ်။ Practical use: Blog posts ကို ORDER BY created_at DESC လို့ရေးပြီး newest first ပြနိုင်ပါတယ်။