-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy path4.3 String Functions.sql
More file actions
71 lines (38 loc) · 956 Bytes
/
4.3 String Functions.sql
File metadata and controls
71 lines (38 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# String Functions
SELECT *
FROM customers
;
SELECT LENGTH('sky');
SELECT first_name, LENGTH(first_name) as Len_first
FROM customers
ORDER BY Len_first
;
SELECT first_name, UPPER(first_name), LOWER(first_name)
FROM customers;
SELECT *
FROM customers;
SELECT ' sky ',TRIM(' sky '), LTRIM(' sky '), RTRIM(' sky ');
SELECT 'I Love SQL', TRIM('I Love SQL');
SELECT LEFT('Alexander',4);
SELECT first_name, LEFT(first_name,3), RIGHT(first_name,3)
FROM customers
;
SELECT SUBSTRING('Alexander',2,3);
SELECT phone,
SUBSTRING(phone,1,3),
SUBSTRING(phone,5,3),
SUBSTRING(phone,9,4),
CONCAT(SUBSTRING(phone,1,3),SUBSTRING(phone,5,3),SUBSTRING(phone,9,4))
FROM customers
;
SELECT REPLACE(first_name,'a','z')
FROM customers
;
SELECT REPLACE(phone,'-','')
FROM customers
;
SELECT LOCATE('x','Alexander');
SELECT first_name, LOCATE('Mic',first_name)
FROM customers
;
SELECT CONCAT('Alex',' Freberg');