{"id":26434,"date":"2024-11-24T13:58:33","date_gmt":"2024-11-24T05:58:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26434\/"},"modified":"2024-11-24T13:58:33","modified_gmt":"2024-11-24T05:58:33","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-mysql-%e6%9f%a5%e8%af%a2%e6%89%be%e5%87%ba%e5%8c%85%e5%90%ab%e9%87%8d%e5%a4%8d%e6%95%b0%e6%8d%ae%e7%9a%84%e8%ae%b0%e5%bd%95%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26434\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MySQL \u67e5\u8be2\u627e\u51fa\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173094518723467.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 MySQL \u67e5\u8be2\u627e\u51fa\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 MySQL \u67e5\u8be2\u627e\u51fa\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u67e5\u627e\u91cd\u590d\u6570\u636e\u7684  \u67e5\u8be2<\/strong><\/p>\n<p>\u5728\u5b9e\u9645\u6570\u636e\u64cd\u4f5c\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u67e5\u627e\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\u3002mysql \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u67e5\u627e\u540c\u65f6\u5177\u6709\u91cd\u590d zxtid \u548c billuuid \u5b57\u6bb5\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>select *\nfrom wx_material\nwhere exists (\n    select 1\n    from wx_material\n    where zxtid = wx_material.zxtid and billuuid = wx_material.billuuid\n    group by zxtid, billuuid\n    having count(*) &gt; 1\n)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u67e5\u8be2\u4f7f\u7528\u5185\u90e8\u67e5\u8be2\u6765\u67e5\u627e\u5b58\u5728\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\uff0c\u7136\u540e\u8fd4\u56de\u5305\u542b\u8fd9\u4e9b\u8bb0\u5f55\u7684\u5916\u90e8\u67e5\u8be2\u3002\u7ed3\u679c\u5c06\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>id   zxtId     billUuid   add\n1    123       A009       0309\u53f7\n2    123       A009       0310\u53f7\n3    126       A011       0315\u53f7\n4    126       A011       0322\u53f7<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6b64\u67e5\u8be2\u8fd4\u56de\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u663e\u793a\u5355\u4e2a\u8bb0\u5f55\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u67e5\u8be2\u627e\u51fa\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\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>\u67e5\u627e\u91cd\u590d\u6570\u636e\u7684 \u67e5\u8be2 \u5728\u5b9e\u9645\u6570\u636e\u64cd\u4f5c\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u67e5\u627e\u5305\u542b\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\u3002mysql \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u67e5\u627e\u540c\u65f6\u5177\u6709\u91cd\u590d zxtid \u548c billuuid \u5b57\u6bb5\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a select * from wx_material where exists ( select 1 from wx_material where zxtid = wx_material.zxtid and billuuid = wx_material.billuuid group by zxtid, billuuid having count(*) &gt; 1 ) \u767b\u5f55\u540e\u590d\u5236 \u6b64\u67e5\u8be2\u4f7f\u7528\u5185\u90e8\u67e5\u8be2\u6765\u67e5\u627e\u5b58\u5728\u91cd\u590d\u6570\u636e\u7684\u8bb0\u5f55\uff0c\u7136\u540e\u8fd4\u56de\u5305\u542b\u8fd9\u4e9b\u8bb0\u5f55\u7684\u5916\u90e8\u67e5\u8be2\u3002\u7ed3\u679c\u5c06\u5982\u4e0b\u6240\u793a\uff1a id zxtId billUuid add 1 123 A009 0309\u53f7 2 123 A009 0310\u53f7 3 126 A011 0315\u53f7 4 [&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-26434","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26434","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=26434"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26434\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}