{"id":7885,"date":"2024-11-14T11:36:56","date_gmt":"2024-11-14T03:36:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7885\/"},"modified":"2024-11-14T11:36:56","modified_gmt":"2024-11-14T03:36:56","slug":"%e5%a6%82%e4%bd%95%e8%ae%be%e8%ae%a1%e8%81%8a%e5%a4%a9%e8%a1%a8%e6%89%8d%e8%83%bd%e5%ae%9e%e7%8e%b0%e7%b1%bb%e4%bc%bc-csdn-%e7%a7%81%e4%bf%a1%e5%8a%9f%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7885\/","title":{"rendered":"\u5982\u4f55\u8bbe\u8ba1\u804a\u5929\u8868\u624d\u80fd\u5b9e\u73b0\u7c7b\u4f3c CSDN \u79c1\u4fe1\u529f\u80fd\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173131507283607.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u8bbe\u8ba1\u804a\u5929\u8868\u624d\u80fd\u5b9e\u73b0\u7c7b\u4f3c CSDN \u79c1\u4fe1\u529f\u80fd\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u8bbe\u8ba1\u804a\u5929\u8868\u624d\u80fd\u5b9e\u73b0\u7c7b\u4f3c CSDN \u79c1\u4fe1\u529f\u80fd\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u804a\u5929\u8868\u5982\u4f55\u8bbe\u8ba1<\/strong><\/p>\n<p>\u5728\u8bbe\u8ba1\u804a\u5929\u8868\u65f6\uff0c\u9700\u8981\u8003\u8651\u5982\u4f55\u5b9e\u73b0\u7c7b\u4f3c\u4e8e csdn \u79c1\u4fe1\u529f\u80fd\u3002\u7ed9\u5b9a\u7684\u8868\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u8868 a\uff1aconversation\uff08\u4f1a\u8bdd\uff09<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u5217\u540d<\/th>\n<th>\u6570\u636e\u7c7b\u578b<\/th>\n<th>\u7ea6\u675f<\/th>\n<th>\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>id<\/td>\n<td>int<\/td>\n<td>\u4e3b\u952e<\/td>\n<td>\u4f1a\u8bdd id<\/td>\n<\/tr>\n<tr>\n<td>send_user<\/td>\n<td>int<\/td>\n<td>\u5916\u952e<\/td>\n<td>\u53d1\u9001\u6d88\u606f\u7684\u7528\u6237 id<\/td>\n<\/tr>\n<tr>\n<td>to_user<\/td>\n<td>int<\/td>\n<td>\u5916\u952e<\/td>\n<td>\u63a5\u6536\u6d88\u606f\u7684\u7528\u6237 id<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u8868 b\uff1amessage\uff08\u6d88\u606f\uff09<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u5217\u540d<\/th>\n<th>\u6570\u636e\u7c7b\u578b<\/th>\n<th>\u7ea6\u675f<\/th>\n<th>\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>id<\/td>\n<td>int<\/td>\n<td>\u4e3b\u952e<\/td>\n<td>\u6d88\u606f id<\/td>\n<\/tr>\n<tr>\n<td>conversation_id<\/td>\n<td>int<\/td>\n<td>\u5916\u952e<\/td>\n<td>\u4f1a\u8bdd id<\/td>\n<\/tr>\n<tr>\n<td>send_user<\/td>\n<td>int<\/td>\n<td>\u5916\u952e<\/td>\n<td>\u53d1\u9001\u6d88\u606f\u7684\u7528\u6237 id<\/td>\n<\/tr>\n<tr>\n<td>message<\/td>\n<td>varchar<\/td>\n<td> <\/td>\n<td>\u6d88\u606f\u5185\u5bb9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<ul>\n<li>\u63a5\u6536\u79c1\u4fe1\u65b9\u5982\u4f55\u83b7\u53d6\u4f1a\u8bdd\u5217\u8868\uff1f<\/li>\n<li>\u7528\u6237 a \u7ed9 b \u53d1\u9001\u4fe1\u606f\u65f6\uff0cb \u65b9\u5982\u4f55\u83b7\u53d6 a \u7ed9 b \u7684\u4f1a\u8bdd\u548c b \u7ed9\u5176\u4ed6\u4eba\u7684\u4f1a\u8bdd\uff1f<\/li>\n<\/ul>\n<p><strong>\u56de\u7b54\uff1a<\/strong><\/p>\n<p>\u867d\u7136\u7ed9\u5b9a\u7684\u8868\u7ed3\u6784\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u6ee1\u8db3\u4e86\u4e0a\u8ff0\u9700\u6c42\uff0c\u4f46\u5b58\u5728\u5c40\u9650\u6027\u3002<\/p>\n<p><strong>\u63a5\u6536\u79c1\u4fe1\u65b9\u83b7\u53d6\u4f1a\u8bdd\u5217\u8868\uff1a<\/strong><\/p>\n<pre>select * from conversation where to_user = b<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>b \u65b9\u83b7\u53d6 a \u7ed9 b \u7684\u4f1a\u8bdd\u548c b \u7ed9\u5176\u4ed6\u4eba\u7684\u4f1a\u8bdd\uff1a<\/strong><\/p>\n<pre>(select * from conversation where to_user = b)\nunion\n(select * from  conversation where  send_user=b)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6539\u8fdb\u540e\u7684\u8868\u8bbe\u8ba1\uff1a<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u5c40\u9650\u6027\u5e76\u63d0\u9ad8\u6027\u80fd\uff0c\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u6539\u8fdb\uff1a<\/p>\n<ul>\n<li>\u5728\u8868 a \u4e2d\u6dfb\u52a0\u5217 latest_message_id\uff0c\u6307\u5411\u6700\u65b0\u6d88\u606f\u7684 id\u3002<\/li>\n<li>\u5728\u8868 b \u4e2d\u6dfb\u52a0\u5217 conversation_alias\uff0c\u7528\u4e8e\u5b58\u50a8\u4f1a\u8bdd\u540d\u79f0\u6216\u522b\u540d\u3002<\/li>\n<\/ul>\n<p><strong>\u6539\u8fdb\u540e\u7684 sql \u67e5\u8be2\uff1a<\/strong><\/p>\n<p><strong>\u63a5\u6536\u79c1\u4fe1\u65b9\u83b7\u53d6\u4f1a\u8bdd\u5217\u8868\uff1a<\/strong><\/p>\n<pre>select * from conversation where to_user = b\norder by latest_message_id desc<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>b \u65b9\u83b7\u53d6 a \u7ed9 b \u7684\u4f1a\u8bdd\u548c b \u7ed9\u5176\u4ed6\u4eba\u7684\u4f1a\u8bdd\uff1a<\/strong><\/p>\n<pre>(select * from conversation where to_user = b)\nunion\n(select * from  conversation where  send_user=b)\norder by latest_message_id desc<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u4e9b\u6539\u8fdb\u53ef\u4ee5\u63d0\u9ad8\u4f1a\u8bdd\u5217\u8868\u7684\u83b7\u53d6\u6548\u7387\uff0c\u5e76\u5141\u8bb8\u901a\u8fc7\u4f1a\u8bdd\u522b\u540d\u6216\u540d\u79f0\u8f7b\u677e\u6807\u8bc6\u4f1a\u8bdd\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u8bbe\u8ba1\u804a\u5929\u8868\u624d\u80fd\u5b9e\u73b0\u7c7b\u4f3c CSDN \u79c1\u4fe1\u529f\u80fd\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>\u804a\u5929\u8868\u5982\u4f55\u8bbe\u8ba1 \u5728\u8bbe\u8ba1\u804a\u5929\u8868\u65f6\uff0c\u9700\u8981\u8003\u8651\u5982\u4f55\u5b9e\u73b0\u7c7b\u4f3c\u4e8e csdn \u79c1\u4fe1\u529f\u80fd\u3002\u7ed9\u5b9a\u7684\u8868\u7ed3\u6784\u5982\u4e0b\uff1a \u8868 a\uff1aconversation\uff08\u4f1a\u8bdd\uff09 \u5217\u540d \u6570\u636e\u7c7b\u578b \u7ea6\u675f \u542b\u4e49 id int \u4e3b\u952e \u4f1a\u8bdd id send_user int \u5916\u952e \u53d1\u9001\u6d88\u606f\u7684\u7528\u6237 id to_user int \u5916\u952e \u63a5\u6536\u6d88\u606f\u7684\u7528\u6237 id \u8868 b\uff1amessage\uff08\u6d88\u606f\uff09 \u5217\u540d \u6570\u636e\u7c7b\u578b \u7ea6\u675f \u542b\u4e49 id int \u4e3b\u952e \u6d88\u606f id conversation_id int \u5916\u952e \u4f1a\u8bdd id send_user int \u5916\u952e \u53d1\u9001\u6d88\u606f\u7684\u7528\u6237 id message varchar \u6d88\u606f\u5185\u5bb9 \u95ee\u9898\uff1a \u63a5\u6536\u79c1\u4fe1\u65b9\u5982\u4f55\u83b7\u53d6\u4f1a\u8bdd\u5217\u8868\uff1f \u7528\u6237 a \u7ed9 b [&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-7885","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7885","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=7885"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7885\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}