-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathString_Functions.sql
22 lines (16 loc) · 1.22 KB
/
String_Functions.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- ---------------------------------------------------------------------------------------------------
-- LENGTH() function returns the length of a string in bytes.
-- ---------------------------------------------------------------------------------------------------
SELECT T.tweet_id
FROM Tweets T
WHERE LENGTH(T.content) > 15;
-- ---------------------------------------------------------------------------------------------------
-- SUBSTRING() function allows us to extract a substring from a string.
-- ---------------------------------------------------------------------------------------------------
SELECT SUBSTRING("DUMMY_STRING", 5, 3) AS Extracted_Substring; -- starts at position 5 and extracts 3 characters.
SELECT LEFT("BUMMY_STRING",3) AS LEFT_SUBSTRING; -- extracts 3 characters from the left of the string.
SELECT RIGHT("BUMMY_STRING",3) AS RIGHT_SUBSTRING; -- extracts 3 characters from the left of the string.
-- -----------------------------------------------------------------------------------------------------
-- REPLACE()
-- -----------------------------------------------------------------------------------------------------
SELECT REPLACE('aashish','a','b'); -- returns a string whose "a" are replaced with "b"