Skip to content

Commit 48d3e62

Browse files
authored
feat: add sql solution to lc problem: No.1919 (doocs#1134)
No.1919.Leetcodify Similar Friends
1 parent 60fdfab commit 48d3e62

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

solution/1900-1999/1919.Leetcodify Similar Friends/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ Friendship table:
106106
<!-- 这里可写当前语言的特殊实现逻辑 -->
107107

108108
```sql
109-
109+
# Write your MySQL query statement below
110+
SELECT DISTINCT user1_id, user2_id
111+
FROM
112+
Friendship AS f
113+
LEFT JOIN Listens AS l1 ON user1_id = l1.user_id
114+
LEFT JOIN Listens AS l2 ON user2_id = l2.user_id
115+
WHERE l1.song_id = l2.song_id AND l1.day = l2.day
116+
GROUP BY 1, 2, l1.day
117+
HAVING count(DISTINCT l1.song_id) >= 3;
110118
```
111119

112120
<!-- tabs:end -->

solution/1900-1999/1919.Leetcodify Similar Friends/README_EN.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ Users 2 and 5 are friends and listened to songs 10, 11, and 12, but they did not
100100
### **SQL**
101101

102102
```sql
103-
103+
# Write your MySQL query statement below
104+
SELECT DISTINCT user1_id, user2_id
105+
FROM
106+
Friendship AS f
107+
LEFT JOIN Listens AS l1 ON user1_id = l1.user_id
108+
LEFT JOIN Listens AS l2 ON user2_id = l2.user_id
109+
WHERE l1.song_id = l2.song_id AND l1.day = l2.day
110+
GROUP BY 1, 2, l1.day
111+
HAVING count(DISTINCT l1.song_id) >= 3;
104112
```
105113

106114
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write your MySQL query statement below
2+
SELECT DISTINCT user1_id, user2_id
3+
FROM
4+
Friendship AS f
5+
LEFT JOIN Listens AS l1 ON user1_id = l1.user_id
6+
LEFT JOIN Listens AS l2 ON user2_id = l2.user_id
7+
WHERE l1.song_id = l2.song_id AND l1.day = l2.day
8+
GROUP BY 1, 2, l1.day
9+
HAVING count(DISTINCT l1.song_id) >= 3;

0 commit comments

Comments
 (0)