LeetCode 180. 连续出现的数字 Posted on 2022-09-15 Edited on 2023-07-04 In 指尖飞舞 , 数据库 , MySQL 摘要:自连接查询。 题目LeetCode 180. 连续出现的数字 自连接MySQL12345678select distinct(a.num) as ConsecutiveNums fromLogs a,Logs b,Logs cwherea.num = b.num and b.num = c.numand a.id = b.id - 1and b.id = c.id - 1; 连续出现三次以上,则主键连续,且值相等。不难想到使用自连接。注意,考虑到同一个值可能存在多个连续片段,所以我们使用 distinct 关键字。 原题链接: LeetCode 180. 连续出现的数字 Post author: zxy Post link: https://ntifs.com/2022/09/15/LeetCode-180-连续出现的数字/ Copyright Notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally.