{"id":7159,"date":"2024-11-14T15:51:50","date_gmt":"2024-11-14T07:51:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7159\/"},"modified":"2024-11-14T15:51:50","modified_gmt":"2024-11-14T07:51:50","slug":"%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%ad%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ad%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8%e5%8f%aa%e5%8c%85%e5%90%ab-2-%e4%b8%aa%e8%8b%b9%e6%9e%9c%e5%92%8c-1-%e4%b8%aa%e9%a6%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7159\/","title":{"rendered":"\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u4e2d\u662f\u5426\u5b58\u5728\u53ea\u5305\u542b 2 \u4e2a\u82f9\u679c\u548c 1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173053891461389.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u4e2d\u662f\u5426\u5b58\u5728\u53ea\u5305\u542b 2 \u4e2a\u82f9\u679c\u548c 1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u4e2d\u662f\u5426\u5b58\u5728\u53ea\u5305\u542b 2 \u4e2a\u82f9\u679c\u548c 1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u591a\u5bf9\u591a\u5173\u8054\u4e2d\u67e5\u8be2\u6307\u5b9a\u5173\u8054\u7ec4\u5b58\u5728\u6027\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728\u5177\u6709\u591a\u5bf9\u591a\u5173\u8054\u5173\u7cfb\u7684\u6570\u636e\u5e93\u8868\u4e2d\uff0c\u6709\u65f6\u9700\u8981\u67e5\u8be2\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u7279\u5b9a\u5173\u8054\u6761\u4ef6\u7684\u7ec4\u3002\u4ee5\u4e0b\u6f14\u793a\u5982\u4f55\u901a\u8fc7sql \u8bed\u53e5\u67e5\u8be2\u7279\u5b9a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1a<\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u6709\u4e00\u4e2a\u6c34\u679c\u8868\u3001\u7bee\u5b50\u8868\u548c\u6c34\u679c\u7bee\u5b50\u5bf9\u5e94\u8868\uff0c\u5176\u4e2d\u5bf9\u5e94\u8868\u8bb0\u5f55\u4e86\u7279\u5b9a\u7bee\u5b50\u4e2d\u6c34\u679c\u7684\u6570\u91cf\u3002\u73b0\u5728\u9700\u8981\u67e5\u8be2\u662f\u5426\u6709\u4e00\u4e2a\u7bee\u5b50\u53ea\u5305\u542b 2 \u4e2a\u548c 1 \u4e2a\u9999\u8549\u3002\u82e5\u5b58\u5728\uff0c\u8fd4\u56de\u7bee\u5b50\u7684\u7f16\u53f7\uff1b\u82e5\u4e0d\u5b58\u5728\uff0c\u65b0\u5efa\u4e00\u4e2a\u8fd9\u6837\u7684\u7bee\u5b50\u3002 <\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<p><strong>\u5224\u65ad\u5b58\u5728\u6027\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p>\u627e\u51fa\u5305\u542b2 \u4e2a\u82f9\u679c\u7684\u7bee\u5b50\uff1a<\/p>\n<pre>select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\u8868 where fruit_id = 2 and count = 2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u627e\u51fa\u5305\u542b1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1a<\/p>\n<pre>select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\u8868 where fruit_id = 3 and count = 1<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u627e\u51fa\u540c\u65f6\u5305\u542b2 \u4e2a\u82f9\u679c\u548c1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1a <\/p>\n<pre>select t3.bucket_id from \n(\n  select t1.bucket_id from\n  (select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\u8868 where fruit_id = 2 and count = 2) t1\n  inner join \n  (select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\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 \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\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 <\/li>\n<\/ol>\n<p>\u4e0a\u8ff0sql \u8bed\u53e5\u67e5\u8be2\u7ed3\u679c\u662f\u5305\u542b2 \u4e2a\u82f9\u679c\u548c1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\u7684\u7f16\u53f7\u3002\u82e5\u7ed3\u679c\u96c6\u4e3a\u7a7a\uff0c\u5219\u8868\u793a\u4e0d\u5b58\u5728\u8fd9\u6837\u7684\u7bee\u5b50\u3002 <\/p>\n<p><strong>\u65b0\u5efa\u7bee\u5b50\uff1a<\/strong><\/p>\n<p>\u6b64\u90e8\u5206\u4e0d\u5728\u672c\u89e3\u7b54\u8303\u56f4\u5185\u3002 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<p>\u4e0a\u8ff0sql \u8bed\u53e5\u5728\u6570\u636e\u91cf\u8f83\u5c0f\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u4f7f\u7528\uff0c\u82e5\u6570\u636e\u91cf\u8f83\u5927\uff0c\u5e94\u8003\u8651\u4f7f\u7528\u66f4\u4f18\u5316\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982\u5de2\u72b6\u67e5\u8be2\u6216\u4f7f\u7528\u7d22\u5f15\u3002 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u4e2d\u662f\u5426\u5b58\u5728\u53ea\u5305\u542b 2 \u4e2a\u548c 1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\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>\u591a\u5bf9\u591a\u5173\u8054\u4e2d\u67e5\u8be2\u6307\u5b9a\u5173\u8054\u7ec4\u5b58\u5728\u6027\u7684\u65b9\u6cd5 \u5728\u5177\u6709\u591a\u5bf9\u591a\u5173\u8054\u5173\u7cfb\u7684\u6570\u636e\u5e93\u8868\u4e2d\uff0c\u6709\u65f6\u9700\u8981\u67e5\u8be2\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u7279\u5b9a\u5173\u8054\u6761\u4ef6\u7684\u7ec4\u3002\u4ee5\u4e0b\u6f14\u793a\u5982\u4f55\u901a\u8fc7sql \u8bed\u53e5\u67e5\u8be2\u7279\u5b9a\u5173\u8054\u7ec4\u662f\u5426\u5b58\u5728\uff1a \u95ee\u9898\uff1a \u5047\u8bbe\u6709\u4e00\u4e2a\u6c34\u679c\u8868\u3001\u7bee\u5b50\u8868\u548c\u6c34\u679c\u7bee\u5b50\u5bf9\u5e94\u8868\uff0c\u5176\u4e2d\u5bf9\u5e94\u8868\u8bb0\u5f55\u4e86\u7279\u5b9a\u7bee\u5b50\u4e2d\u6c34\u679c\u7684\u6570\u91cf\u3002\u73b0\u5728\u9700\u8981\u67e5\u8be2\u662f\u5426\u6709\u4e00\u4e2a\u7bee\u5b50\u53ea\u5305\u542b 2 \u4e2a\u548c 1 \u4e2a\u9999\u8549\u3002\u82e5\u5b58\u5728\uff0c\u8fd4\u56de\u7bee\u5b50\u7684\u7f16\u53f7\uff1b\u82e5\u4e0d\u5b58\u5728\uff0c\u65b0\u5efa\u4e00\u4e2a\u8fd9\u6837\u7684\u7bee\u5b50\u3002 \u89e3\u7b54\uff1a \u5224\u65ad\u5b58\u5728\u6027\uff1a \u627e\u51fa\u5305\u542b2 \u4e2a\u82f9\u679c\u7684\u7bee\u5b50\uff1a select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\u8868 where fruit_id = 2 and count = 2 \u767b\u5f55\u540e\u590d\u5236 \u627e\u51fa\u5305\u542b1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1a select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\u8868 where fruit_id = 3 and count = 1 \u767b\u5f55\u540e\u590d\u5236 \u627e\u51fa\u540c\u65f6\u5305\u542b2 \u4e2a\u82f9\u679c\u548c1 \u4e2a\u9999\u8549\u7684\u7bee\u5b50\uff1a select t3.bucket_id from ( select t1.bucket_id from (select bucket_id from \u6c34\u679c\u7c43\u5b50\u5c0d\u61c9\u8868 [&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-7159","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7159","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=7159"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7159\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}