[{"data":1,"prerenderedAt":106},["ShallowReactive",2],{"term-o\u002Forder-by":3,"related-o\u002Forder-by":95},{"id":4,"title":5,"acronym":6,"body":7,"category":77,"description":78,"difficulty":79,"extension":80,"letter":81,"meta":82,"navigation":83,"path":84,"related":85,"seo":89,"sitemap":90,"stem":93,"subcategory":6,"__hash__":94},"terms\u002Fterms\u002Fo\u002Forder-by.md","ORDER BY",null,{"type":8,"value":9,"toc":71},"minimark",[10,15,19,23,26,30,60,64,67],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"ORDER BY sorts your query results. Add DESC for newest first, ASC for oldest first. Without ORDER BY, the database returns rows in whatever order it feels like — which is not always consistent.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"ORDER BY sorts the result set by one or more columns in ascending (ASC, default) or descending (DESC) order. Sorting happens after WHERE and GROUP BY filtering. Without ORDER BY, the order of rows in a query result is not guaranteed by the database.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","SELECT name, created_at\nFROM users\nORDER BY created_at DESC, name ASC;\n","sql","",[38,39,40,48,54],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"SELECT name, created_at\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"FROM users\n",[41,55,57],{"class":43,"line":56},3,[41,58,59],{},"ORDER BY created_at DESC, name ASC;\n",[11,61,63],{"id":62},"when-youll-hear-this","When You'll Hear This",[16,65,66],{},"\"ORDER BY created_at DESC to show the newest users first.\" \u002F \"Don't rely on the default sort order — always specify ORDER BY.\"",[68,69,70],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":72},[73,74,75,76],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":62,"depth":50,"text":63},"database","ORDER BY sorts your query results. Add DESC for newest first, ASC for oldest first.","beginner","md","o",{},true,"\u002Fterms\u002Fo\u002Forder-by",[86,87,88],"SELECT","GROUP BY","LIMIT",{"title":5,"description":78},{"changefreq":91,"priority":92},"weekly",0.7,"terms\u002Fo\u002Forder-by","cyOP52flBhOybOcVM7E5qVFFixviEpRFr_-cttCFJ3s",[96,100,103],{"title":87,"path":97,"acronym":6,"category":77,"difficulty":98,"description":99},"\u002Fterms\u002Fg\u002Fgroup-by","intermediate","GROUP BY collapses rows with the same value into one group so you can count, sum, or average them. 'How many orders per user?' — GROUP BY user_id.",{"title":88,"path":101,"acronym":6,"category":77,"difficulty":79,"description":102},"\u002Fterms\u002Fl\u002Flimit","LIMIT caps how many rows a query returns. If your users table has 1 million rows, you do not want to load all of them at once.",{"title":86,"path":104,"acronym":6,"category":77,"difficulty":79,"description":105},"\u002Fterms\u002Fs\u002Fselect","SELECT is how you ask a database to give you data. It is the 'Read' in CRUD.",1776518298679]