-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL_querying_8_String_functions.sql
More file actions
61 lines (31 loc) · 1009 Bytes
/
SQL_querying_8_String_functions.sql
File metadata and controls
61 lines (31 loc) · 1009 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
#### This script is for use with the Parks_and_Rec database created with: MySQL-YouTube-Series/Beginner - Parks_and_Rec_Create_db.sql
## String functions
SELECT LENGTH('skyfall');
SELECT frist_name, LENGTH(first_name) AS length
FROM employee_demographics
ORDER BY length;
SELECT UPPER('sky');
SELECT LOWER('SKY');
SELECT frist_name, UPPER(first_name) AS name_upper
FROM employee_demographics
;
SELECT TRIM(' sky ');
# removes leading and trailing whitespace
SELECT LTRIM(' sky ');
SELECT RTRIM(' sky ');
SELECT first_name,
LEFT(first_name,4),
RIGHT(first_name,4),
SUBSTRING(first_name, 3,2),
birth_date,
SUBSTRING(birth_date, 6,2) AS birth_month
FROM employee_demographics
;
SELECT first_name, REPLACE(first_name, 'a', 'z')
FROM employee_demographics
SELECT LOCATE('x','Alexander')
SELECT first_name, LOCATE('An', first_name)
FROM employee_demographics
SELECT first_name, last_name,
CONCAT(first_name, ' ', last_name) AS full_name
FROM employee_demographics