{"id":3152,"date":"2023-10-20T11:14:23","date_gmt":"2023-10-20T03:14:23","guid":{"rendered":"https:\/\/white-night.club\/?p=3152"},"modified":"2023-11-09T11:07:47","modified_gmt":"2023-11-09T03:07:47","slug":"ad79","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/20\/ad79\/","title":{"rendered":"180.\u00a0\u8fde\u7eed\u51fa\u73b0\u7684\u6570\u5b57"},"content":{"rendered":"\n<p>\u8868\uff1a<code>Logs<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| id          | int     |\n| num         | varchar |\n+-------------+---------+\n\u5728 SQL \u4e2d\uff0cid \u662f\u8be5\u8868\u7684\u4e3b\u952e\u3002\nid \u662f\u4e00\u4e2a\u81ea\u589e\u5217\u3002<\/pre>\n\n\n\n<p>\u627e\u51fa\u6240\u6709\u81f3\u5c11\u8fde\u7eed\u51fa\u73b0\u4e09\u6b21\u7684\u6570\u5b57\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u7684\u7ed3\u679c\u8868\u4e2d\u7684\u6570\u636e\u53ef\u4ee5\u6309&nbsp;<strong>\u4efb\u610f\u987a\u5e8f<\/strong>&nbsp;\u6392\u5217\u3002<\/p>\n\n\n\n<p>\u7ed3\u679c\u683c\u5f0f\u5982\u4e0b\u9762\u7684\u4f8b\u5b50\u6240\u793a\uff1a<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>\nLogs \u8868\uff1a\n+----+-----+\n| id | num |\n+----+-----+\n| 1  | 1   |\n| 2  | 1   |\n| 3  | 1   |\n| 4  | 2   |\n| 5  | 1   |\n| 6  | 2   |\n| 7  | 2   |\n+----+-----+\n<strong>\u8f93\u51fa\uff1a<\/strong>\nResult \u8868\uff1a\n+-----------------+\n| ConsecutiveNums |\n+-----------------+\n| 1               |\n+-----------------+\n<strong>\u89e3\u91ca\uff1a<\/strong>1 \u662f\u552f\u4e00\u8fde\u7eed\u51fa\u73b0\u81f3\u5c11\u4e09\u6b21\u7684\u6570\u5b57\u3002<\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>INNER JOIN<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8fde\u7eed\u51fa\u73b0xxx\uff0c\u76f4\u63a5\u7528\u4e24\u6b21\u81ea\u8054\u7ed3\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e00\u6b21\u81ea\u8054\u7ed3\uff0c\u751f\u6210\u4e86\u4e00\u5f20\u865a\u62df\u8868\uff08\u5982\u4e0b\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+----+-----+\n| A.id | B.id |\n+----+-----+\n| 1  | 2   |\n| 2  | 3   |\n| 3  | 4   |\n| 4  | 5   |\n| 5  | 6   |\n| 6  | 7   |\n+----+-----+<\/pre>\n\n\n\n<p>\u7b2c\u4e8c\u6b21\u81ea\u8054\u7ed3\uff0c\u865a\u62df\u8868\u53d8\u6210\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">+----+----+----+\n| A.id | B.id | C.id|\n+----+----+----+\n| 1  |     2   |    3   |\n| 2  |     3   |    4   |\n| 3  |     4   |    5   |\n| 4  |     5   |    6   |\n| 5  |     6   |    7   |\n+----+----+----+<\/pre>\n\n\n\n<p>\u7531\u4e8e\u4e00\u4e2a\u6570\u53ef\u80fd\u8fde\u7eed\u51fa\u73b04\u6b21\u4ee5\u4e0a\uff0c\u6240\u4ee5\u8981\u53bb\u91cd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Write your MySQL query statement below\nSELECT DISTINCT A.num AS ConsecutiveNums\nFROM Logs AS A \nINNER JOIN Logs AS B \nON A.id+1=B.id \nINNER JOIN Logs AS C \nON A.id+2=C.id\nWHERE A.num=B.num AND A.num=C.num<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u81ea\u8054\u7ed3 INNER JOIN<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3152"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=3152"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3152\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=3152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}