{"id":225771,"date":"2020-12-11T10:43:31","date_gmt":"2020-12-11T02:43:31","guid":{"rendered":"http:\/\/4563.org\/?p=225771"},"modified":"2020-12-11T10:43:31","modified_gmt":"2020-12-11T02:43:31","slug":"%e8%ae%bf%e5%ae%a2%e8%ae%b0%e5%bd%95%e8%a1%a8%e5%8e%bb%e9%87%8d%ef%bc%8c%e6%9c%89%e4%bb%80%e4%b9%88%e6%af%94%e8%be%83%e5%a5%bd%e7%9a%84%e6%96%b9%e6%b3%95%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=225771","title":{"rendered":"\u8bbf\u5ba2\u8bb0\u5f55\u8868\u53bb\u91cd\uff0c\u6709\u4ec0\u4e48\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bbf\u5ba2\u8bb0\u5f55\u8868\u53bb\u91cd\uff0c\u6709\u4ec0\u4e48\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gaojiangouyu <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6570\u636e\u5e93\uff1aMySQL \u73b0\u72b6\uff1a\u6709\u4e00\u4e2a\u8bbf\u5ba2\u5386\u53f2\u8868\uff0c(id,uid,visitor_id,visit_datetime) visit_history<\/p>\n<p>\u9700\u6c42\uff1a\u67e5\u8be2\u4e00\u4e2a\u7528\u6237\u4e3b\u9875\u5386\u53f2\u88ab\u8bbf\u95ee\u8bb0\u5f55\uff0c\u540c\u4e00\u4e2a\u8bbf\u5ba2\u5982\u679c\u591a\u6b21\u8bbf\u95ee\u5219\u53ea\u5c55\u793a\u6700\u65b0\u7684\u4e00\u6bd4\u8bb0\u5f55<\/p>\n<p>sql:<\/p>\n<pre><code>select u.* from visit_history u join(select max(id) id from visit_history where uid = xxx group by visitor_id) um on u.id = um.id <\/code><\/pre>\n<p>\u8fd9\u4e2a\u67e5\u8be2\u7531\u4e8e\u9700\u8981\u5bf9 visitor_id \u8fdb\u884c\u53bb\u91cd\uff08\u5373\u4fbf\u5728 uid \u4e0a\u5efa\u7acb\u4e86\u76f8\u5173\u7d22\u5f15\uff09\u5bfc\u81f4\u6027\u80fd\u53ca\u5176\u4f4e\u4e0b\uff0cmysql \u6709\u529e\u6cd5\u5904\u7406\u8fd9\u79cd\u67e5\u8be2\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4571748\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rekulas <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u770b\u61c2\u4ec0\u4e48\u64cd\u4f5c \u53d6\u6700\u65b0\u7684\u76f4\u63a5 order \u53d6\u4e0d\u5c31\u884c\u4e86 \u5f3a\u884c\u52a0\u4e2a group \u518d join \u662f\u4e3a\u5565\u5462                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4571749\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : crclz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u770b\u90a3\u6761\u67e5\u8be2\u7684\u6027\u80fd\u5206\u6790                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4571750\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wangritian <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u8868\u76f4\u63a5 group by visitor_id \u8bd5\u8bd5\uff1f<br \/>\u6362\u4e2a\u89d2\u5ea6\uff0c\u591a\u6b21\u8bbf\u95ee\u53ea\u505a update\uff0c\u786e\u4fdd\u53ea\u5b58\u5728\u4e00\u6761\u8bb0\u5f55\uff0c\u5728\u4e1a\u52a1\u4e0a\u662f\u5426\u5141\u8bb8\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4571751\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qyqx5538 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             select t.id,t.uid,max(t.visit_datetime) from visit_history t group by t.uid order;<br \/>\u9ad8\u7248\u672c\u7684 mysql \u53ef\u80fd\u4f1a\u56e0\u4e3a ONLY_FULL_GROUP_BY \u7684\u7ea6\u675f\u62a5\u9519\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4571752\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : telami <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             select * from (select * from visit_history where uid = 1 ORDER BY visit_datetime desc limit 99999999) GROUP BY visitor_id;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbf\u5ba2\u8bb0\u5f55\u8868\u53bb\u91cd\uff0c\u6709\u4ec0\u4e48\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/225771"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=225771"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/225771\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=225771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=225771"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=225771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}