{"id":26372,"date":"2024-11-24T12:12:28","date_gmt":"2024-11-24T04:12:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26372\/"},"modified":"2024-11-24T12:12:28","modified_gmt":"2024-11-24T04:12:28","slug":"%e5%85%b3%e8%81%94%e6%9f%a5%e8%af%a2%ef%bc%9a%e4%b8%80%e6%ad%a5%e5%88%b0%e4%bd%8d%e8%bf%98%e6%98%af%e6%8b%86%e5%88%86%e6%9f%a5%e8%af%a2%ef%bc%8c%e5%93%aa%e7%a7%8d%e6%9b%b4%e6%9c%89%e6%95%88%e7%8e%87-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26372\/","title":{"rendered":"\u5173\u8054\u67e5\u8be2\uff1a\u4e00\u6b65\u5230\u4f4d\u8fd8\u662f\u62c6\u5206\u67e5\u8be2\uff0c\u54ea\u79cd\u66f4\u6709\u6548\u7387\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173089872468619.jpg\" class=\"aligncenter\" title=\"\u5173\u8054\u67e5\u8be2\uff1a\u4e00\u6b65\u5230\u4f4d\u8fd8\u662f\u62c6\u5206\u67e5\u8be2\uff0c\u54ea\u79cd\u66f4\u6709\u6548\u7387\uff1f\u63d2\u56fe\" alt=\"\u5173\u8054\u67e5\u8be2\uff1a\u4e00\u6b65\u5230\u4f4d\u8fd8\u662f\u62c6\u5206\u67e5\u8be2\uff0c\u54ea\u79cd\u66f4\u6709\u6548\u7387\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5173\u8054\u67e5\u8be2\u7684\u4e24\u79cd\u5b9e\u73b0\u65b9\u5f0f<\/strong><\/p>\n<p>\u5bf9\u4e8e\u5173\u8054\u67e5\u8be2\uff0c\u53ef\u4ee5\u4f7f\u7528 join \u4e00\u6b65\u5230\u4f4d\uff0c\u6216\u62c6\u5206\u6210\u4e24\u6b21\u67e5\u8868\u3002<\/p>\n<p><strong>\u65b9\u5f0f\u4e00\uff1ajoin \u4e00\u6b65\u5230\u4f4d<\/strong><\/p>\n<pre>select\n    ...\nfrom\n    `friendships_friendship`\n    left outer join `auth_user` t3 on (\n        `friendships_friendship`.`from_user_id` = t3.`id`\n    )\nwhere\n    `friendships_friendship`.`to_user_id` = 1\nlimit\n    21;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u4e00\u6b21\u67e5\u8be2\u5373\u53ef\u83b7\u53d6\u6240\u6709\u4fe1\u606f\uff0c\u6548\u7387\u66f4\u9ad8\u3002<\/p>\n<p><strong>\u65b9\u5f0f\u4e8c\uff1a\u62c6\u5206\u6210\u4e24\u6b21\u67e5\u8868<\/strong><\/p>\n<pre>-- \u83b7\u53d6 id\nSELECT\n    ...\nFROM\n    `friendships_friendship`\nWHERE\n    `friendships_friendship`.`to_user_id` = 1\nLIMIT\n    21;\n\n-- \u4f7f\u7528 in \u64cd\u4f5c\u7b26\u67e5\u8be2\nSELECT\n    ...\nFROM\n    `auth_user` T3\nWHERE\n    T3.`from_user_id` in (xxxx, xxx, xxxx)\nLIMIT\n    21;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u9700\u8981\u4e24\u6b21\u67e5\u8be2\uff0c\u6548\u7387\u8f83\u4f4e\u3002<\/p>\n<p><strong> \u5173\u8054\u67e5\u8be2\u6267\u884c\u987a\u5e8f<\/strong><\/p>\n<p>\u5bf9\u4e8e\u5173\u8054\u67e5\u8be2\uff0cmysql \u4f1a\u5148\u6267\u884c where \u6761\u4ef6\uff0c\u518d\u8fdb\u884c join \u64cd\u4f5c\u3002<\/p>\n<p>\u5728\u65b9\u5f0f\u4e00\u4e2d\uff0c\u4f1a\u5148\u627e\u5230 friendships_friendship.to_user_id = 1 \u7684\u8bb0\u5f55\uff0c\u518d\u8fdb\u884c join \u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u8868\u4e2d\u6570\u636e\u91cf\u8f83\u5927\uff0c\u4f7f\u7528\u7684\u65b9\u5f0f\u4e0d\u540c\uff0c\u6267\u884c\u6548\u7387\u4e5f\u4f1a\u6709\u5f88\u5927\u5dee\u5f02\u3002\u53e6\u5916\uff0c\u62c6\u5206\u67e5\u8be2\u540e\uff0c\u9700\u8981\u786e\u4fdd\u4e24\u6b21\u67e5\u8be2\u7684\u9650\u5236\u6761\u4ef6\u4e00\u81f4\uff0c\u624d\u80fd\u5f97\u5230\u6b63\u786e\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5173\u8054\u67e5\u8be2\uff1a\u4e00\u6b65\u5230\u4f4d\u8fd8\u662f\u62c6\u5206\u67e5\u8be2\uff0c\u54ea\u79cd\u66f4\u6709\u6548\u7387\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>\u5173\u8054\u67e5\u8be2\u7684\u4e24\u79cd\u5b9e\u73b0\u65b9\u5f0f \u5bf9\u4e8e\u5173\u8054\u67e5\u8be2\uff0c\u53ef\u4ee5\u4f7f\u7528 join \u4e00\u6b65\u5230\u4f4d\uff0c\u6216\u62c6\u5206\u6210\u4e24\u6b21\u67e5\u8868\u3002 \u65b9\u5f0f\u4e00\uff1ajoin \u4e00\u6b65\u5230\u4f4d select &#8230; from `friendships_friendship` left outer join `auth_user` t3 on ( `friendships_friendship`.`from_user_id` = t3.`id` ) where `friendships_friendship`.`to_user_id` = 1 limit 21; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u79cd\u65b9\u5f0f\u4e00\u6b21\u67e5\u8be2\u5373\u53ef\u83b7\u53d6\u6240\u6709\u4fe1\u606f\uff0c\u6548\u7387\u66f4\u9ad8\u3002 \u65b9\u5f0f\u4e8c\uff1a\u62c6\u5206\u6210\u4e24\u6b21\u67e5\u8868 &#8212; \u83b7\u53d6 id SELECT &#8230; FROM `friendships_friendship` WHERE `friendships_friendship`.`to_user_id` = 1 LIMIT 21; &#8212; \u4f7f\u7528 in \u64cd\u4f5c\u7b26\u67e5\u8be2 SELECT &#8230; FROM `auth_user` T3 WHERE T3.`from_user_id` in [&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-26372","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26372","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=26372"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26372\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}