{"id":235,"date":"2023-02-24T05:55:38","date_gmt":"2023-02-23T21:55:38","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=235"},"modified":"2023-04-30T15:21:29","modified_gmt":"2023-04-30T07:21:29","slug":"mysql-sorting","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/24\/mysql-sorting\/","title":{"rendered":"MySQL \u6392\u5e8f"},"content":{"rendered":"<p>\u5982\u679c\u6211\u4eec\u9700\u8981\u5bf9<code>SELECT<\/code>\u8bfb\u53d6\u7684\u6570\u636e\u8fdb\u884c\u6392\u5e8f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528MySQL\u7684<code>ORDER BY<\/code>\u5b50\u53e5\u6765\u8bbe\u5b9a\u4f60\u60f3\u6309\u54ea\u4e2a\u5b57\u6bb5\u54ea\u79cd\u65b9\u5f0f\u6765\u8fdb\u884c\u6392\u5e8f\uff0c\u518d\u8fd4\u56de\u641c\u7d22\u7ed3\u679c\u3002<\/p>\n<h2>ORDER BY \u8bed\u6cd5<\/h2>\n<p><!-- more --><\/p>\n<p>\u4ee5\u4e0b\u662f<code>SQL SELECT<\/code>\u8bed\u53e5\u4f7f\u7528<code>ORDER BY<\/code>\u5b50\u53e5\u5c06\u67e5\u8be2\u6570\u636e\u6392\u5e8f\u540e\u518d\u8fd4\u56de\u6570\u636e\uff1a<\/p>\n<pre><code class=\"language-sql\">SELECT field1, field2,...fieldN FROM table_name1, table_name2...\nORDER BY field1 [ASC [DESC][\u9ed8\u8ba4 ASC]], [field2...] [ASC [DESC][\u9ed8\u8ba4 ASC]]<\/code><\/pre>\n<h2>MySQL \u62fc\u97f3\u6392\u5e8f<\/h2>\n<p>\u5982\u679c\u5b57\u7b26\u96c6\u91c7\u7528\u7684\u662fGBK(\u6c49\u5b57\u7f16\u7801\u5b57\u7b26\u96c6)\uff0c\u76f4\u63a5\u5728\u67e5\u8be2\u8bed\u53e5\u540e\u8fb9\u6dfb\u52a0 ORDER BY\uff1a<\/p>\n<pre><code class=\"language-sql\">SELECT * \nFROM appblog_tbl\nORDER BY appblog_title;<\/code><\/pre>\n<p>\u5982\u679c\u5b57\u7b26\u96c6\u91c7\u7528\u7684\u662fUTF-8(\u4e07\u56fd\u7801)\uff0c\u9700\u8981\u5148\u5bf9\u5b57\u6bb5\u8fdb\u884c\u8f6c\u7801\u7136\u540e\u6392\u5e8f\uff1a<\/p>\n<pre><code class=\"language-sql\">SELECT * \nFROM appblog_tbl\nORDER BY CONVERT(appblog_title using gbk);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u6211\u4eec\u9700\u8981\u5bf9SELECT\u8bfb\u53d6\u7684\u6570\u636e\u8fdb\u884c\u6392\u5e8f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528MySQL\u7684ORDER BY\u5b50\u53e5\u6765\u8bbe\u5b9a\u4f60\u60f3\u6309\u54ea\u4e2a\u5b57 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}