{"id":7435,"date":"2024-11-14T09:25:28","date_gmt":"2024-11-14T01:25:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7435\/"},"modified":"2024-11-14T09:25:28","modified_gmt":"2024-11-14T01:25:28","slug":"%e6%b2%a1%e6%9c%89%e5%bc%80%e7%aa%97%e5%87%bd%e6%95%b0%ef%bc%8c%e5%a6%82%e4%bd%95%e7%ad%9b%e9%80%89%e5%a4%a7%e6%95%b0%e6%8d%ae%e8%a1%a8%e4%b8%ad%e7%9b%b8%e9%82%bb%e6%95%b0%e6%8d%ae%e5%b7%ae%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7435\/","title":{"rendered":"\u6ca1\u6709\u5f00\u7a97\u51fd\u6570\uff0c\u5982\u4f55\u7b5b\u9009\u5927\u6570\u636e\u8868\u4e2d\u76f8\u90bb\u6570\u636e\u5dee\u503c\u8d85\u8fc7 5 \u5206\u949f\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173085337862216.jpg\" class=\"aligncenter\" title=\"\u6ca1\u6709\u5f00\u7a97\u51fd\u6570\uff0c\u5982\u4f55\u7b5b\u9009\u5927\u6570\u636e\u8868\u4e2d\u76f8\u90bb\u6570\u636e\u5dee\u503c\u8d85\u8fc7 5 \u5206\u949f\uff1f\u63d2\u56fe\" alt=\"\u6ca1\u6709\u5f00\u7a97\u51fd\u6570\uff0c\u5982\u4f55\u7b5b\u9009\u5927\u6570\u636e\u8868\u4e2d\u76f8\u90bb\u6570\u636e\u5dee\u503c\u8d85\u8fc7 5 \u5206\u949f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7b5b\u9009\u5927\u6570\u636e\u8868\u4e2d\u76f8\u90bb\u6570\u636e\u5dee\u503c\u8d85\u8fc7 5 \u5206\u949f<\/strong><\/p>\n<p>\u7531\u4e8e\u6570\u636e\u5e93\u7248\u672c\u9650\u5236\uff0c\u65e0\u6cd5\u4f7f\u7528\u5f00\u7a97\u51fd\u6570\u3002\u4ee5\u4e0b\u63d0\u4f9b\u4e86\u51e0\u79cd\u66ff\u4ee3\u65b9\u6848\uff1a<\/p>\n<p><strong>\u65b9\u6848 1\uff1a\u4f7f\u7528\u4e34\u65f6\u53d8\u91cf<\/strong><\/p>\n<pre>set @tmp = '2000-1-1';\nselect * from (\n  select *,\n    timestampdiff(second, @tmp, time) as diff,\n    @tmp := time\n  from \u8868\u540d\n) as t1\nwhere diff &gt; 300;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8be5\u8bed\u53e5\u901a\u8fc7\u4e34\u65f6\u53d8\u91cf @tmp \u6765\u5b58\u50a8\u4e0a\u4e00\u6761\u8bb0\u5f55\u7684\u65f6\u95f4\uff0c\u5e76\u4e0e\u5f53\u524d\u8bb0\u5f55\u7684\u65f6\u95f4\u5dee\u8fdb\u884c\u6bd4\u8f83\uff0c\u5dee\u503c\u5927\u4e8e 300 \u79d2\u5219\u8f93\u51fa\u8be5\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u65b9\u6848 2\uff1a\u751f\u6210\u65b0\u8868<\/strong><\/p>\n<pre>select * from \u8868 as a\nleft join \u8868 as b on a.\u4e3b\u952e = b.\u4e3b\u952e+1\nwhere timestampdiff(second, a.time, b.time) &gt; 300;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u65b9\u6848\u901a\u8fc7\u521b\u5efa\u81ea\u589e\u4e3b\u952e\u5b57\u6bb5\uff0c\u7136\u540e\u4f7f\u7528\u8fde\u63a5\u6761\u4ef6\u6765\u6bd4\u8f83\u76f8\u90bb\u4e24\u6761\u8bb0\u5f55\u7684\u65f6\u95f4\u5dee\u3002<\/p>\n<p><strong>\u65b9\u6848 3\uff1a\u51cf\u5c11\u9009\u62e9\u5b57\u6bb5<\/strong><\/p>\n<pre>set @i = 0; set @j = 0;\nselect *, a2 - a1\nfrom (\n  select *, @i := @i + 1 as a1 from lag1\n) as t1\nleft join (\n  select *, @j := @j + 1 as a2 from lag1\n) as t2 on t1.a1 + 1 = t2.a2 ;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8be5\u65b9\u6848\u901a\u8fc7\u51cf\u5c11\u9009\u62e9\u5b57\u6bb5\u6765\u63d0\u9ad8\u6027\u80fd\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b83\u9700\u8981\u521b\u5efa\u526f\u672c\u8868 lag1\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6ca1\u6709\u5f00\u7a97\u51fd\u6570\uff0c\u5982\u4f55\u7b5b\u9009\u5927\u6570\u636e\u8868\u4e2d\u76f8\u90bb\u6570\u636e\u5dee\u503c\u8d85\u8fc7 5 \u5206\u949f\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>\u7b5b\u9009\u5927\u6570\u636e\u8868\u4e2d\u76f8\u90bb\u6570\u636e\u5dee\u503c\u8d85\u8fc7 5 \u5206\u949f \u7531\u4e8e\u6570\u636e\u5e93\u7248\u672c\u9650\u5236\uff0c\u65e0\u6cd5\u4f7f\u7528\u5f00\u7a97\u51fd\u6570\u3002\u4ee5\u4e0b\u63d0\u4f9b\u4e86\u51e0\u79cd\u66ff\u4ee3\u65b9\u6848\uff1a \u65b9\u6848 1\uff1a\u4f7f\u7528\u4e34\u65f6\u53d8\u91cf set @tmp = &#8216;2000-1-1&#8217;; select * from ( select *, timestampdiff(second, @tmp, time) as diff, @tmp := time from \u8868\u540d ) as t1 where diff &gt; 300; \u767b\u5f55\u540e\u590d\u5236 \u8be5\u8bed\u53e5\u901a\u8fc7\u4e34\u65f6\u53d8\u91cf @tmp \u6765\u5b58\u50a8\u4e0a\u4e00\u6761\u8bb0\u5f55\u7684\u65f6\u95f4\uff0c\u5e76\u4e0e\u5f53\u524d\u8bb0\u5f55\u7684\u65f6\u95f4\u5dee\u8fdb\u884c\u6bd4\u8f83\uff0c\u5dee\u503c\u5927\u4e8e 300 \u79d2\u5219\u8f93\u51fa\u8be5\u8bb0\u5f55\u3002 \u65b9\u6848 2\uff1a\u751f\u6210\u65b0\u8868 select * from \u8868 as a left join \u8868 as b on a.\u4e3b\u952e = [&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-7435","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7435","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=7435"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7435\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}