{"id":48966,"date":"2024-12-02T12:36:51","date_gmt":"2024-12-02T04:36:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48966\/"},"modified":"2024-12-02T12:36:51","modified_gmt":"2024-12-02T04:36:51","slug":"%e5%a6%82%e4%bd%95%e6%8c%89%e7%85%a7%e7%8a%b6%e6%80%81%e5%af%b9%e8%ae%a2%e5%8d%95%e8%a1%a8%e6%95%b0%e6%8d%ae%e6%8e%92%e5%ba%8f%ef%bc%8c%e4%bc%98%e5%85%88%e5%b1%95%e7%a4%ba%e7%8a%b6%e6%80%81%e4%b8%ba-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48966\/","title":{"rendered":"\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300a\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241105\/173078104867299f78c01c9.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>mysql \u67e5\u8be2\u8ba2\u5355\u8868\u6309\u7167\u72b6\u6001\u6392\u5e8f (-1 \u6c38\u8fdc\u6392\u6700\u540e\uff0c2 \u6392\u6700\u524d)<\/strong><\/p>\n<p>\u5982\u4f55\u5c06\u8ba2\u5355\u8868\u4e2d\u7684\u6570\u636e\u6309\u7167\u72b6\u6001\u6392\u5e8f\uff0c\u4f7f\u5f97\u72b6\u6001\u4e3a -1 \u7684\u8ba2\u5355\u6c38\u8fdc\u6392\u5728\u6700\u540e\uff0c\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\u6c38\u8fdc\u6392\u5728\u6700\u524d\uff0c\u5176\u4ed6\u72b6\u6001\u6309\u7167\u5347\u5e8f\u6392\u5217\uff1f<\/p>\n<p><strong>sql \u67e5\u8be2<\/strong><\/p>\n<pre>select * from (select case when status==2 then 7,\nwhen status==-1 then -1\nend as newStatus,status from order_table) m order by newStatus desc;<\/pre>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<p>\u8be5\u67e5\u8be2\u4f7f\u7528\u4e86 mysql \u7684 case \u8868\u8fbe\u5f0f\u5c06\u4e0d\u540c\u7684\u72b6\u6001\u6620\u5c04\u5230\u65b0\u7684\u6392\u5e8f\u79cd\u5b50 newstatus \u4e2d\uff1a<\/p>\n<ul>\n<li>\u5f53\u72b6\u6001\u4e3a 2 \u65f6\uff0c\u6620\u5c04\u5230 7\uff08\u6700\u524d\uff09<\/li>\n<li>\u5f53\u72b6\u6001\u4e3a -1 \u65f6\uff0c\u6620\u5c04\u5230 -1\uff08\u6700\u540e\uff09<\/li>\n<li>\u5176\u4ed6\u72b6\u6001\u4fdd\u6301\u4e0d\u53d8<\/li>\n<\/ul>\n<p>\u7136\u540e\uff0c\u6309\u7167 newstatus \u964d\u5e8f\u6392\u5217\uff0c\u5373\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\u6392\u5728\u6700\u524d\uff0c\u72b6\u6001\u4e3a -1 \u7684\u8ba2\u5355\u6392\u5728\u6700\u540e\uff0c\u5176\u4ed6\u72b6\u6001\u6309\u7167\u5347\u5e8f\u6392\u5217\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1aphp \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f \u6536\u85cf \u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300a\u5982\u4f55\u6309\u7167\u72b6\u6001\u5bf9\u8ba2\u5355\u8868\u6570\u636e\u6392\u5e8f\uff0c\u4f18\u5148\u5c55\u793a\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01 mysql \u67e5\u8be2\u8ba2\u5355\u8868\u6309\u7167\u72b6\u6001\u6392\u5e8f (-1 \u6c38\u8fdc\u6392\u6700\u540e\uff0c2 \u6392\u6700\u524d) \u5982\u4f55\u5c06\u8ba2\u5355\u8868\u4e2d\u7684\u6570\u636e\u6309\u7167\u72b6\u6001\u6392\u5e8f\uff0c\u4f7f\u5f97\u72b6\u6001\u4e3a -1 \u7684\u8ba2\u5355\u6c38\u8fdc\u6392\u5728\u6700\u540e\uff0c\u72b6\u6001\u4e3a 2 \u7684\u8ba2\u5355\u6c38\u8fdc\u6392\u5728\u6700\u524d\uff0c\u5176\u4ed6\u72b6\u6001\u6309\u7167\u5347\u5e8f\u6392\u5217\uff1f sql \u67e5\u8be2 select * from (select case when status==2 then 7, when status==-1 then -1 end as newStatus,status from order_table) m order by newStatus desc; \u8bf4\u660e\uff1a \u8be5\u67e5\u8be2\u4f7f\u7528\u4e86 mysql \u7684 case \u8868\u8fbe\u5f0f\u5c06\u4e0d\u540c\u7684\u72b6\u6001\u6620\u5c04\u5230\u65b0\u7684\u6392\u5e8f\u79cd\u5b50 newstatus \u4e2d\uff1a \u5f53\u72b6\u6001\u4e3a 2 \u65f6\uff0c\u6620\u5c04\u5230 7\uff08\u6700\u524d\uff09 \u5f53\u72b6\u6001\u4e3a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48966","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48966"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48966\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}