{"id":27335,"date":"2024-11-24T14:11:10","date_gmt":"2024-11-24T06:11:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27335\/"},"modified":"2024-11-24T14:11:10","modified_gmt":"2024-11-24T06:11:10","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-mysql-%e7%bb%9f%e8%ae%a1-json-%e6%95%b0%e7%bb%84%e4%b8%ad%e7%89%b9%e5%ae%9a%e5%85%83%e7%b4%a0%e7%9a%84%e4%bd%bf%e7%94%a8%e9%a2%91%e7%8e%87%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27335\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1 JSON \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173123046471832.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1 JSON \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1 JSON \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728  \u4e2d\u7edf\u8ba1 json \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387<\/strong><\/p>\n<p>\u60f3\u8981\u7edf\u8ba1 json \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387\uff0c\u4e0b\u9762\u662f\u4e00\u79cd\u53ef\u884c\u7684\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u4f7f\u7528 json_search \u51fd\u6570<\/strong><\/p>\n<p>\u867d\u7136 mysql 5.7 \u7248\u672c\u6ca1\u6709 json_table \u51fd\u6570\uff0c\u4f46\u4ecd\u53ef\u4ee5\u4f7f\u7528 json_search \u51fd\u6570\u6765\u67e5\u627e json \u6570\u7ec4\u4e2d\u6307\u5b9a\u5143\u7d20\u7684\u5b58\u5728\uff1a<\/p>\n<pre>SELECT\n    COUNT( JSON_SEARCH( tags, 'one', \"3467562849402896\" ) ),\n    COUNT( JSON_SEARCH( tags, 'one', \"3467562861985809\" ) ),\n    COUNT( JSON_SEARCH( tags, 'one', \"3465044211793921\" ) )\nFROM\n    XXXXXXXXXX<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6bb5\u67e5\u8be2\u8fd4\u56de\u7279\u5b9a\u5143\u7d20\u5728 json \u6570\u7ec4\u4e2d\u51fa\u73b0\u7684\u6b21\u6570\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c&#8221;one&#8221; \u662f json \u6570\u7ec4\u7684\u952e\u540d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1 JSON \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728 \u4e2d\u7edf\u8ba1 json \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387 \u60f3\u8981\u7edf\u8ba1 json \u6570\u7ec4\u4e2d\u7279\u5b9a\u5143\u7d20\u7684\u4f7f\u7528\u9891\u7387\uff0c\u4e0b\u9762\u662f\u4e00\u79cd\u53ef\u884c\u7684\u65b9\u6cd5\uff1a \u4f7f\u7528 json_search \u51fd\u6570 \u867d\u7136 mysql 5.7 \u7248\u672c\u6ca1\u6709 json_table \u51fd\u6570\uff0c\u4f46\u4ecd\u53ef\u4ee5\u4f7f\u7528 json_search \u51fd\u6570\u6765\u67e5\u627e json \u6570\u7ec4\u4e2d\u6307\u5b9a\u5143\u7d20\u7684\u5b58\u5728\uff1a SELECT COUNT( JSON_SEARCH( tags, &#8216;one&#8217;, &#8220;3467562849402896&#8221; ) ), COUNT( JSON_SEARCH( tags, &#8216;one&#8217;, &#8220;3467562861985809&#8221; ) ), COUNT( JSON_SEARCH( tags, &#8216;one&#8217;, &#8220;3465044211793921&#8221; ) ) FROM XXXXXXXXXX \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6bb5\u67e5\u8be2\u8fd4\u56de\u7279\u5b9a\u5143\u7d20\u5728 json \u6570\u7ec4\u4e2d\u51fa\u73b0\u7684\u6b21\u6570\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c&#8221;one&#8221; \u662f json \u6570\u7ec4\u7684\u952e\u540d\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1 JSON [&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-27335","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27335","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=27335"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27335\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}