{"id":7116,"date":"2024-11-14T13:00:32","date_gmt":"2024-11-14T05:00:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7116\/"},"modified":"2024-11-14T13:00:32","modified_gmt":"2024-11-14T05:00:32","slug":"%e5%a6%82%e4%bd%95%e7%bb%9f%e8%ae%a1-mysql-%e8%a1%a8%e4%b8%ad-clip_url_hash-%e5%88%97%e7%9a%84%e7%a9%ba%e5%80%bc%e3%80%81%e7%a9%ba%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%92%8c%e9%9d%9e%e7%a9%ba%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7116\/","title":{"rendered":"\u5982\u4f55\u7edf\u8ba1 MySQL \u8868\u4e2d clip_url_hash \u5217\u7684\u7a7a\u503c\u3001\u7a7a\u5b57\u7b26\u4e32\u548c\u975e\u7a7a\u503c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173045688492920.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7edf\u8ba1 MySQL \u8868\u4e2d clip_url_hash \u5217\u7684\u7a7a\u503c\u3001\u7a7a\u5b57\u7b26\u4e32\u548c\u975e\u7a7a\u503c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7edf\u8ba1 MySQL \u8868\u4e2d clip_url_hash \u5217\u7684\u7a7a\u503c\u3001\u7a7a\u5b57\u7b26\u4e32\u548c\u975e\u7a7a\u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u67e5\u8be2\u4e2d\u4f7f\u7528 group by \u540e\u6dfb\u52a0\u5224\u65ad\u6761\u4ef6<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\uff0c\u4f7f\u7528 group by \u5b50\u53e5\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u65f6\uff0c\u53ef\u4ee5\u6dfb\u52a0\u5224\u65ad\u6761\u4ef6\u6765\u8fc7\u6ee4\u6216\u805a\u5408\u7279\u5b9a\u7c7b\u522b\u7684\u6570\u636e\u3002<\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4f55\u7edf\u8ba1 mysql \u8868\u4e2d clip_url_hash \u5217\u4e2d\u7684\u4e09\u79cd\u60c5\u51b5\uff1a\u4e3a null\u3001\u4e3a\u7a7a\u5b57\u7b26 (&#8220;) \u548c\u6709\u5b9e\u9645\u503c\uff08\u957f\u5ea6\u5927\u4e8e 0\uff09\uff1f<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 case when \u8868\u8fbe\u5f0f\u6765\u5224\u65ad\u6bcf\u4e2a clip_url_hash \u7684\u60c5\u51b5\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u5217 checks \u6765\u5b58\u50a8\u8fd9\u4e9b\u60c5\u51b5\u3002\u7136\u540e\u4f7f\u7528\u65b0\u7684 checks \u5217\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u5e76\u8ba1\u7b97 count\u3002<\/p>\n<p><strong>sql \u8bed\u53e5\uff1a<\/strong><\/p>\n<pre>select \n    d.checks, count(d.checks)\nfrom (select (\n    case clip_url_hash\n    when '' then '\u7a7a\u5b57\u7b26\u4e32'\n    when null then 'null'\n    else '\u6b63\u5e38\u7684' end\n) as checks from text_meta_ingest) as d\ngroup by d.checks;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7ed3\u679c\uff1a<\/strong><\/p>\n<pre>checks  | count\n--------|--------\n\u7a7a\u5b57\u7b26\u4e32 | 10\nNULL    | 15\n\u6b63\u5e38\u7684  | 120<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7edf\u8ba1 MySQL \u8868\u4e2d clip_url_hash \u5217\u7684\u7a7a\u503c\u3001\u7a7a\u5b57\u7b26\u4e32\u548c\u975e\u7a7a\u503c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u8be2\u4e2d\u4f7f\u7528 group by \u540e\u6dfb\u52a0\u5224\u65ad\u6761\u4ef6 \u5728 mysql \u4e2d\uff0c\u4f7f\u7528 group by \u5b50\u53e5\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u65f6\uff0c\u53ef\u4ee5\u6dfb\u52a0\u5224\u65ad\u6761\u4ef6\u6765\u8fc7\u6ee4\u6216\u805a\u5408\u7279\u5b9a\u7c7b\u522b\u7684\u6570\u636e\u3002 \u95ee\u9898\uff1a \u5982\u4f55\u7edf\u8ba1 mysql \u8868\u4e2d clip_url_hash \u5217\u4e2d\u7684\u4e09\u79cd\u60c5\u51b5\uff1a\u4e3a null\u3001\u4e3a\u7a7a\u5b57\u7b26 (&#8220;) \u548c\u6709\u5b9e\u9645\u503c\uff08\u957f\u5ea6\u5927\u4e8e 0\uff09\uff1f \u89e3\u51b3\u65b9\u6848\uff1a \u4f7f\u7528 case when \u8868\u8fbe\u5f0f\u6765\u5224\u65ad\u6bcf\u4e2a clip_url_hash \u7684\u60c5\u51b5\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u5217 checks \u6765\u5b58\u50a8\u8fd9\u4e9b\u60c5\u51b5\u3002\u7136\u540e\u4f7f\u7528\u65b0\u7684 checks \u5217\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u5e76\u8ba1\u7b97 count\u3002 sql \u8bed\u53e5\uff1a select d.checks, count(d.checks) from (select ( case clip_url_hash when &#8221; then &#8216;\u7a7a\u5b57\u7b26\u4e32&#8217; when null then &#8216;null&#8217; else &#8216;\u6b63\u5e38\u7684&#8217; end ) as [&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-7116","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7116","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=7116"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7116\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}