{"id":6919,"date":"2024-11-14T12:59:58","date_gmt":"2024-11-14T04:59:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6919\/"},"modified":"2024-11-14T12:59:58","modified_gmt":"2024-11-14T04:59:58","slug":"mysql-%e6%9f%a5%e8%af%a2%e9%94%99%e8%af%af%ef%bc%9a%e6%8b%ac%e5%8f%b7%e4%b8%8d%e5%8c%b9%e9%85%8d%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6919\/","title":{"rendered":"MySQL \u67e5\u8be2\u9519\u8bef\uff1a\u62ec\u53f7\u4e0d\u5339\u914d\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173007846320695.jpg\" class=\"aligncenter\" title=\"MySQL \u67e5\u8be2\u9519\u8bef\uff1a\u62ec\u53f7\u4e0d\u5339\u914d\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"MySQL \u67e5\u8be2\u9519\u8bef\uff1a\u62ec\u53f7\u4e0d\u5339\u914d\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u67e5\u8be2\u9519\u8bef\uff1a\u62ec\u53f7\u4e0d\u5339\u914d<\/strong><\/p>\n<p>\u4f60\u5728\u6267\u884cmysql\u67e5\u8be2\u65f6\u9047\u5230\u4e86\u4e00\u4e2a\u9519\u8bef\uff0c\u9519\u8bef\u4fe1\u606f\u4e2d\u63d0\u5230\u62ec\u53f7\u4e0d\u6210\u5bf9\u3002\u8ba9\u6211\u4eec\u4ed4\u7ec6\u68c0\u67e5\u4e00\u4e0b\u4f60\u7684\u67e5\u8be2\uff1a<\/p>\n<pre>select p.*\nfrom product as p, product_product_category as c\nwhere p.deleting = 0 and (\n  p.product_category_id in (1, 2)\n  or (\n    p.product_id = c.product_id\n    and c.product_category_id in (1, 2)\n  )\n)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b63\u5982\u9519\u8bef\u4fe1\u606f\u6240\u63d0\u793a\uff0c\u8be5\u67e5\u8be2\u4e2d\u786e\u5b9e\u6709\u62ec\u53f7\u4e0d\u5339\u914d\u7684\u60c5\u51b5\u3002\u4ed4\u7ec6\u89c2\u5bdf\uff0c\u4f60\u4f1a\u53d1\u73b0\u5de6\u62ec\u53f7\u6709 6 \u4e2a\uff0c\u800c\u53f3\u62ec\u53f7\u53ea\u6709 5 \u4e2a\u3002\u8fd9\u4f1a\u5bfc\u81f4mysql\u65e0\u6cd5\u6b63\u786e\u89e3\u6790\u67e5\u8be2\uff0c\u5e76\u629b\u51fa\u9519\u8bef\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u9519\u8bef\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u62ec\u53f7\u6210\u5bf9\u51fa\u73b0\u3002\u4fee\u6539\u540e\u7684\u67e5\u8be2\u5982\u4e0b\uff1a<\/p>\n<pre>select p.*\nfrom product as p, product_product_category as c\nwhere p.deleting = 0 and (\n  p.product_category_id in (1, 2)\n  or (\n    p.product_id = c.product_id\n    and c.product_category_id in (1, 2)\n  )\n)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5de6\u53f3\u62ec\u53f7\u6570\u76ee\u76f8\u540c\uff0c\u67e5\u8be2\u5e94\u8be5\u80fd\u6b63\u5e38\u6267\u884c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u67e5\u8be2\u9519\u8bef\uff1a\u62ec\u53f7\u4e0d\u5339\u914d\uff0c\u5982\u4f55\u89e3\u51b3\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\u9519\u8bef\uff1a\u62ec\u53f7\u4e0d\u5339\u914d \u4f60\u5728\u6267\u884cmysql\u67e5\u8be2\u65f6\u9047\u5230\u4e86\u4e00\u4e2a\u9519\u8bef\uff0c\u9519\u8bef\u4fe1\u606f\u4e2d\u63d0\u5230\u62ec\u53f7\u4e0d\u6210\u5bf9\u3002\u8ba9\u6211\u4eec\u4ed4\u7ec6\u68c0\u67e5\u4e00\u4e0b\u4f60\u7684\u67e5\u8be2\uff1a select p.* from product as p, product_product_category as c where p.deleting = 0 and ( p.product_category_id in (1, 2) or ( p.product_id = c.product_id and c.product_category_id in (1, 2) ) ) \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u6b63\u5982\u9519\u8bef\u4fe1\u606f\u6240\u63d0\u793a\uff0c\u8be5\u67e5\u8be2\u4e2d\u786e\u5b9e\u6709\u62ec\u53f7\u4e0d\u5339\u914d\u7684\u60c5\u51b5\u3002\u4ed4\u7ec6\u89c2\u5bdf\uff0c\u4f60\u4f1a\u53d1\u73b0\u5de6\u62ec\u53f7\u6709 6 \u4e2a\uff0c\u800c\u53f3\u62ec\u53f7\u53ea\u6709 5 \u4e2a\u3002\u8fd9\u4f1a\u5bfc\u81f4mysql\u65e0\u6cd5\u6b63\u786e\u89e3\u6790\u67e5\u8be2\uff0c\u5e76\u629b\u51fa\u9519\u8bef\u3002 \u8981\u89e3\u51b3\u6b64\u9519\u8bef\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u62ec\u53f7\u6210\u5bf9\u51fa\u73b0\u3002\u4fee\u6539\u540e\u7684\u67e5\u8be2\u5982\u4e0b\uff1a select p.* from product as p, product_product_category as c where p.deleting = 0 and [&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-6919","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6919","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=6919"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6919\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}