diff --git a/solution/1900-1999/1919.Leetcodify Similar Friends/README.md b/solution/1900-1999/1919.Leetcodify Similar Friends/README.md index 01970f3e7e26b..151ccbf15989f 100644 --- a/solution/1900-1999/1919.Leetcodify Similar Friends/README.md +++ b/solution/1900-1999/1919.Leetcodify Similar Friends/README.md @@ -106,7 +106,15 @@ Friendship table: ```sql - +# Write your MySQL query statement below +SELECT DISTINCT user1_id, user2_id +FROM + Friendship AS f + LEFT JOIN Listens AS l1 ON user1_id = l1.user_id + LEFT JOIN Listens AS l2 ON user2_id = l2.user_id +WHERE l1.song_id = l2.song_id AND l1.day = l2.day +GROUP BY 1, 2, l1.day +HAVING count(DISTINCT l1.song_id) >= 3; ``` diff --git a/solution/1900-1999/1919.Leetcodify Similar Friends/README_EN.md b/solution/1900-1999/1919.Leetcodify Similar Friends/README_EN.md index bd41f41bce53c..223e20ab617db 100644 --- a/solution/1900-1999/1919.Leetcodify Similar Friends/README_EN.md +++ b/solution/1900-1999/1919.Leetcodify Similar Friends/README_EN.md @@ -100,7 +100,15 @@ Users 2 and 5 are friends and listened to songs 10, 11, and 12, but they did not ### **SQL** ```sql - +# Write your MySQL query statement below +SELECT DISTINCT user1_id, user2_id +FROM + Friendship AS f + LEFT JOIN Listens AS l1 ON user1_id = l1.user_id + LEFT JOIN Listens AS l2 ON user2_id = l2.user_id +WHERE l1.song_id = l2.song_id AND l1.day = l2.day +GROUP BY 1, 2, l1.day +HAVING count(DISTINCT l1.song_id) >= 3; ``` diff --git a/solution/1900-1999/1919.Leetcodify Similar Friends/Solution.sql b/solution/1900-1999/1919.Leetcodify Similar Friends/Solution.sql new file mode 100644 index 0000000000000..76ab3963271e6 --- /dev/null +++ b/solution/1900-1999/1919.Leetcodify Similar Friends/Solution.sql @@ -0,0 +1,9 @@ +# Write your MySQL query statement below +SELECT DISTINCT user1_id, user2_id +FROM + Friendship AS f + LEFT JOIN Listens AS l1 ON user1_id = l1.user_id + LEFT JOIN Listens AS l2 ON user2_id = l2.user_id +WHERE l1.song_id = l2.song_id AND l1.day = l2.day +GROUP BY 1, 2, l1.day +HAVING count(DISTINCT l1.song_id) >= 3;