{"id":7733,"date":"2024-11-14T13:30:04","date_gmt":"2024-11-14T05:30:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7733\/"},"modified":"2024-11-14T13:30:04","modified_gmt":"2024-11-14T05:30:04","slug":"mysql-%e4%b8%ad%e5%ad%98%e5%82%a8%e5%a4%9a%e5%80%bc%e7%b1%bb%e6%95%b0%e6%8d%ae%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%80%97%e5%8f%b7%e5%88%86%e9%9a%94%e5%80%bc%e8%bf%98%e6%98%af%e5%85%b3%e7%b3%bb%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7733\/","title":{"rendered":"MySQL \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e\uff1a\u4f7f\u7528\u9017\u53f7\u5206\u9694\u503c\u8fd8\u662f\u5173\u7cfb\u8868\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173120744737564.jpg\" class=\"aligncenter\" title=\"MySQL \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e\uff1a\u4f7f\u7528\u9017\u53f7\u5206\u9694\u503c\u8fd8\u662f\u5173\u7cfb\u8868\uff1f\u63d2\u56fe\" alt=\"MySQL \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e\uff1a\u4f7f\u7528\u9017\u53f7\u5206\u9694\u503c\u8fd8\u662f\u5173\u7cfb\u8868\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728  \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e<\/strong><\/p>\n<p>mysql \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e\uff08\u5982\u591a\u4e2a\u7528\u6237 id\uff09\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u51e0\u79cd\u65b9\u6cd5\uff0c\u4f8b\u5982\u9017\u53f7\u5206\u9694\u503c\u6216\u5173\u7cfb\u8868\u3002<\/p>\n<p><strong>\u4f7f\u7528\u9017\u53f7\u5206\u9694\u503c<\/strong><\/p>\n<p>\u8fd9\u662f\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u53ea\u9700\u5c06\u6bcf\u4e2a\u503c\u7528\u9017\u53f7\u5206\u9694\u5e76\u5b58\u50a8\u5728\u5355\u4e2a\u5b57\u6bb5\u4e2d\u5373\u53ef\u3002\u4f8b\u5982\uff1a<\/p>\n<p>\u8868\u7ed3\u6784\uff1a<\/p>\n<pre>\u9519\u8bef\u8868 (id int not null, \u7528\u6237 id text not null)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u63d2\u5165\u6570\u636e\uff1a<\/p>\n<pre>insert into \u9519\u8bef\u8868 (id, \u7528\u6237 id) values (1, '1,2,3')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u67e5\u8be2\u6570\u636e\uff1a<\/p>\n<pre>select * from \u9519\u8bef\u8868 where \u7528\u6237 id like '%2%'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u5173\u7cfb\u8868<\/strong><\/p>\n<p>\u8fd9\u662f\u4e00\u79cd\u66f4\u89c4\u8303\u7684\u65b9\u6cd5\uff0c\u5c06\u6570\u636e\u5b58\u50a8\u5728\u5355\u72ec\u7684\u8868\u4e2d\uff0c\u5176\u4e2d\u6bcf\u4e2a\u8bb0\u5f55\u8868\u793a\u4e00\u4e2a\u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<p>\u8868\u7ed3\u6784\uff1a<\/p>\n<pre>\u9519\u8bef\u8868 (id int not null, \u7528\u6237 id int not null)\n\u7528\u6237\u8868 (id int not null, \u540d\u79f0 text not null)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u63d2\u5165\u6570\u636e\uff1a<\/p>\n<pre>insert into \u9519\u8bef\u8868 (id, \u7528\u6237 id) values (1, 1)\ninsert into \u9519\u8bef\u8868 (id, \u7528\u6237 id) values (2, 1)\ninsert into \u9519\u8bef\u8868 (id, \u7528\u6237 id) values (3, 2)\ninsert into \u7528\u6237\u8868 (id, \u540d\u79f0) values (1, '\u7528\u6237 1')\ninsert into \u7528\u6237\u8868 (id, \u540d\u79f0) values (2, '\u7528\u6237 2')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u67e5\u8be2\u6570\u636e\uff1a<\/p>\n<pre>SELECT u.\u540d\u79f0, e.ID\nFROM \u9519\u8bef\u8868 e\nJOIN \u7528\u6237\u8868 u ON u.ID = e.\u7528\u6237 ID\nWHERE u.\u540d\u79f0 = '\u7528\u6237 1'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u65b9\u6cd5\u5141\u8bb8\u8f7b\u677e\u67e5\u8be2\u548c\u66f4\u65b0\u6570\u636e\uff0c\u540c\u65f6\u4fdd\u6301\u6570\u636e\u5b8c\u6574\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e\uff1a\u4f7f\u7528\u9017\u53f7\u5206\u9694\u503c\u8fd8\u662f\u5173\u7cfb\u8868\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>\u5728 \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e mysql \u4e2d\u5b58\u50a8\u591a\u503c\u7c7b\u6570\u636e\uff08\u5982\u591a\u4e2a\u7528\u6237 id\uff09\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u51e0\u79cd\u65b9\u6cd5\uff0c\u4f8b\u5982\u9017\u53f7\u5206\u9694\u503c\u6216\u5173\u7cfb\u8868\u3002 \u4f7f\u7528\u9017\u53f7\u5206\u9694\u503c \u8fd9\u662f\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u53ea\u9700\u5c06\u6bcf\u4e2a\u503c\u7528\u9017\u53f7\u5206\u9694\u5e76\u5b58\u50a8\u5728\u5355\u4e2a\u5b57\u6bb5\u4e2d\u5373\u53ef\u3002\u4f8b\u5982\uff1a \u8868\u7ed3\u6784\uff1a \u9519\u8bef\u8868 (id int not null, \u7528\u6237 id text not null) \u767b\u5f55\u540e\u590d\u5236 \u63d2\u5165\u6570\u636e\uff1a insert into \u9519\u8bef\u8868 (id, \u7528\u6237 id) values (1, &#8216;1,2,3&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u67e5\u8be2\u6570\u636e\uff1a select * from \u9519\u8bef\u8868 where \u7528\u6237 id like &#8216;%2%&#8217; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5173\u7cfb\u8868 \u8fd9\u662f\u4e00\u79cd\u66f4\u89c4\u8303\u7684\u65b9\u6cd5\uff0c\u5c06\u6570\u636e\u5b58\u50a8\u5728\u5355\u72ec\u7684\u8868\u4e2d\uff0c\u5176\u4e2d\u6bcf\u4e2a\u8bb0\u5f55\u8868\u793a\u4e00\u4e2a\u503c\u3002\u4f8b\u5982\uff1a \u8868\u7ed3\u6784\uff1a \u9519\u8bef\u8868 (id int not null, \u7528\u6237 id int not null) \u7528\u6237\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-7733","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7733","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=7733"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7733\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}