{"id":7156,"date":"2024-11-14T11:03:09","date_gmt":"2024-11-14T03:03:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7156\/"},"modified":"2024-11-14T11:03:09","modified_gmt":"2024-11-14T03:03:09","slug":"%e5%a6%82%e4%bd%95%e9%ab%98%e6%95%88%e6%9f%a5%e8%af%a2%e5%a4%9a%e5%af%b9%e5%a4%9a%e5%85%b3%e8%81%94%e7%bb%84%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7156\/","title":{"rendered":"\u5982\u4f55\u9ad8\u6548\u67e5\u8be2\u591a\u5bf9\u591a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173053640213220.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u9ad8\u6548\u67e5\u8be2\u591a\u5bf9\u591a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u9ad8\u6548\u67e5\u8be2\u591a\u5bf9\u591a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u8be2\u591a\u5bf9\u591a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1f<\/strong><\/p>\n<p>\u5728\u591a\u5bf9\u591a\u5173\u8054\u5173\u7cfb\u4e2d\uff0c\u4e00\u4e2a\u5143\u7d20\u53ef\u4ee5\u4e0e\u591a\u4e2a\u5176\u4ed6\u5143\u7d20\u5173\u8054\u3002\u5f53\u9700\u8981\u67e5\u8be2\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u7279\u5b9a\u7684\u5173\u8054\u7ec4\u65f6\uff0c\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p>\u4f8b\u5982\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u6c34\u679c\u548c\u7bee\u5b50\u7684\u5173\u7cfb\uff0c\u5176\u4e2d\u6c34\u679c\u7bee\u5b50\u5305\u542b\u6c34\u679c\u548c\u6570\u91cf\uff0c\u9700\u6c42\u662f\u67e5\u8be2\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u7bee\u5b50\u5305\u542b\u4e24\u4e2a\u548c\u4e00\u4e2a\u9999\u8549\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u9996\u5148\u7b5b\u9009\u51fa\u5305\u542b\u4e24\u4e2a\u82f9\u679c\u548c\u4e00\u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1a<\/p>\n<pre>select bucket_id from \u5bf9\u5e94\u8868 where fruit_id = 2 and count = 2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u518d\u6839\u636e\u7b5b\u9009\u51fa\u7684\u7bee\u5b50id\uff0c\u6392\u9664\u5305\u542b\u5176\u4ed6\u6c34\u679c\u7684\u7bee\u5b50\uff1a<\/p>\n<pre>select bucket_id\nfrom \u5bf9\u5e94\u8868\ngroup by bucket_id\nhaving count(1) = 2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6700\u540e\uff0c\u6bd4\u8f83\u4e24\u4e2a\u67e5\u8be2\u7ed3\u679c\uff0c\u5373\u53ef\u786e\u5b9a\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684\u5173\u8054\u7ec4\uff1a<\/p>\n<pre>select t3.bucket_id from \n(\n  select t1.bucket_id from\n  (select bucket_id from \u5bf9\u5e94\u8868 where fruit_id = 2 and count = 2) t1\n  inner join \n  (select bucket_id from \u5bf9\u5e94\u8868 where fruit_id = 3 and count = 1) t2\n  on t1.bucket_id = t2.bucket_id\n) t3,\n(\n  select bucket_id\n  from \u5bf9\u5e94\u8868\n  group by bucket_id\n  having count(1) = 2\n) t4\nwhere t3.bucket_id = t4.bucket_id<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u65b9\u6cd5\u5bf9\u4e8e\u6570\u636e\u91cf\u8f83\u5c0f\u7684\u60c5\u51b5\u662f\u53ef\u884c\u7684\uff0c\u4f46\u5bf9\u4e8e\u5927\u6570\u636e\u91cf\uff0c\u53ef\u80fd\u4f1a\u6709\u6027\u80fd\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u9ad8\u6548\u67e5\u8be2\u591a\u5bf9\u591a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\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>\u5982\u4f55\u67e5\u8be2\u591a\u5bf9\u591a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1f \u5728\u591a\u5bf9\u591a\u5173\u8054\u5173\u7cfb\u4e2d\uff0c\u4e00\u4e2a\u5143\u7d20\u53ef\u4ee5\u4e0e\u591a\u4e2a\u5176\u4ed6\u5143\u7d20\u5173\u8054\u3002\u5f53\u9700\u8981\u67e5\u8be2\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u7279\u5b9a\u7684\u5173\u8054\u7ec4\u65f6\uff0c\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u4f8b\u5982\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u6c34\u679c\u548c\u7bee\u5b50\u7684\u5173\u7cfb\uff0c\u5176\u4e2d\u6c34\u679c\u7bee\u5b50\u5305\u542b\u6c34\u679c\u548c\u6570\u91cf\uff0c\u9700\u6c42\u662f\u67e5\u8be2\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u7bee\u5b50\u5305\u542b\u4e24\u4e2a\u548c\u4e00\u4e2a\u9999\u8549\u3002 \u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u9996\u5148\u7b5b\u9009\u51fa\u5305\u542b\u4e24\u4e2a\u82f9\u679c\u548c\u4e00\u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1a select bucket_id from \u5bf9\u5e94\u8868 where fruit_id = 2 and count = 2 \u767b\u5f55\u540e\u590d\u5236 \u518d\u6839\u636e\u7b5b\u9009\u51fa\u7684\u7bee\u5b50id\uff0c\u6392\u9664\u5305\u542b\u5176\u4ed6\u6c34\u679c\u7684\u7bee\u5b50\uff1a select bucket_id from \u5bf9\u5e94\u8868 group by bucket_id having count(1) = 2 \u767b\u5f55\u540e\u590d\u5236 \u6700\u540e\uff0c\u6bd4\u8f83\u4e24\u4e2a\u67e5\u8be2\u7ed3\u679c\uff0c\u5373\u53ef\u786e\u5b9a\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684\u5173\u8054\u7ec4\uff1a select t3.bucket_id from ( select t1.bucket_id from (select bucket_id from \u5bf9\u5e94\u8868 where fruit_id = 2 and count = 2) t1 inner join (select bucket_id [&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-7156","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7156","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=7156"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7156\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}