Lesson 6 Flashcards
String manipulation (10 cards)
1
Q
String data can be notoriously difficult and annoying to work with because:
A
- It can be a pain to get strings in the correct format you want
- String data can have a lot of variation and mistakes, which can be hard to account for
2
Q
There are SO many string manipulation functions you can use to modify and manipulate strings— honestly too many to learn and remember!
Do NOT stress about learning them all because:
A
You can easily Google or ChatGPT the syntax as you have different goals and use cases come up.
3
Q
How can you change a column name?
For example, from the orders
table:
- Pull the
order_id
column - Pull the
order_id
column and rename it tonickname_order_id
A
AS
- Alias
- You can rename your columns at any time, as anything you want
SELECT order_id, order_id AS nickname_order_id FROM orders
4
Q
len()
A
5
Q
concat()
A
6
Q
replace()
A
-
replace()
is a great function to sort through strings and replace a certain part with something else - Can replace with an empty string
''
7
Q
trim()
A
- chop off part of a string
8
Q
ltrim()
A
left trim
9
Q
rtrim()
A
right trim
10
Q
split_part()
A
- A delimiter is a separator