Skip to content

Commit 1fd2b64

Browse files
authored
Create count-occurrences-in-text.sql
1 parent c5f46b1 commit 1fd2b64

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

MySQL/count-occurrences-in-text.sql

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
SELECT "bull" AS word, SUM(IF(content LIKE "% bull %", 1, 0)) AS count
5+
FROM Files
6+
UNION ALL
7+
SELECT "bear" AS word, SUM(IF(content LIKE "% bear %", 1, 0)) AS count
8+
FROM Files;

0 commit comments

Comments
 (0)