{"id":90,"date":"2020-10-09T14:46:06","date_gmt":"2020-10-09T06:46:06","guid":{"rendered":"http:\/\/blog.ohmmx.com\/?p=90"},"modified":"2022-01-24T15:25:07","modified_gmt":"2022-01-24T07:25:07","slug":"%e7%a9%ba%e5%80%bc%e6%8e%92%e5%ba%8f%e6%9f%a5%e8%af%a2","status":"publish","type":"post","link":"http:\/\/blog.ohmmx.com\/?p=90","title":{"rendered":"\u7a7a\u503c\u6392\u5e8f\u67e5\u8be2"},"content":{"rendered":"\n<p>\u5728\u8868\u91cc\u67d0\u4e2a\u5b57\u6bb5\u542b\u6709\u7a7a\u503c\uff08NULL\uff09\uff0c\u8fd9\u65f6\u5019\u60f3\u628a\u7a7a\u503c\u7684\u7edf\u4e00\u6392\u5230\u524d\u9762\u6216\u8005\u540e\u9762\uff0c\u7136\u540e\u5e76\u4e0d\u5f71\u54cd\u5176\u4ed6\u6709\u503c\u8bb0\u5f55\u7684\u6b63\u5e38\u6392\u5e8f\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e00\uff1a\u5728\u6392\u5e8f\u91cc\u6dfb\u52a0\u5224\u65ad<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM TABLE1 t ORDER BY t.COL1 IS NULL, t.COL1; -- \u7a7a\u503c\u6392\u540e\nSELECT * FROM TABLE1 t ORDER BY t.COL1 IS NOT NULL, t.COL1; -- \u7a7a\u503c\u6392\u524d<\/code><\/pre>\n\n\n\n<p>\u540c\u7406\u4e5f\u53ef\u4ee5\u4f7f\u7528 IFNULL() \u6216\u8005 ISNULL() \u7b49\u65b9\u6cd5\u5728\u6392\u5e8f\u91cc\u8fdb\u884c\u5224\u65ad\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd5\u4e8c\uff1a\u5c06\u7a7a\u503c\u5b57\u6bb5\u6253\u4e2a\u6807\u8bb0\uff0c\u518d\u4f7f\u7528\u5185\u8054\u89c6\u56fe\u8fdb\u884c\u4e8c\u6b21\u67e5\u8be2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT\n\t* \nFROM\n\t( SELECT t.*, CASE WHEN t.COL1 IS NULL OR t.COL1 = '' THEN 1 ELSE 0 END IS_NULL FROM TABLE1 t ) v \nORDER BY\n\tv.IS_NULL DESC,\n\tv.COL1<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u8868\u91cc\u67d0\u4e2a\u5b57\u6bb5\u542b\u6709\u7a7a\u503c\uff08NULL\uff09\uff0c\u8fd9\u65f6\u5019\u60f3\u628a\u7a7a\u503c\u7684\u7edf\u4e00\u6392\u5230\u524d\u9762\u6216\u8005\u540e\u9762\uff0c\u7136\u540e\u5e76 &hellip; <a href=\"http:\/\/blog.ohmmx.com\/?p=90\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[9,8],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-17","tag-mysql","tag-8"],"_links":{"self":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":3,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":128,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions\/128"}],"wp:attachment":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}