substring
-- ๋ฌธ์์ด์ ์ผ๋ถ๋ถ๋ง ๊ฐ์ ธ์ค๋ ํจ์ substring()
-- ์ฑ
์ ๋ชฉ์ ์ฒซ๊ธ์๋ถํฐ ์ด๋ฒ์งธ ๊ธ์๊น์ง๋ง ๊ฐ์ ธ์ค์์ค
-- substring ํจ์์ ์์ ์์น๋ 1๋ถํฐ๋ค
select substring(title,1,10) as title, pages, released_year
from books;
-- ์ ๋ชฉ์, ๋งจ ๋ค์์ 5๋ฒ์งธ ๊ธ์๋ถํฐ ๋๊น์ง ๋ค ๋์ค๋๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค์์ค
select substring(title,-5) as title
from books;
-- ์ ๋ชฉ์ ์์์ 3๋ฒ์งธ ๊ธ์๋ถํฐ ๋๊น์ง ๋ค ๋์ค๋๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค์์ค
select substring(title,3) as title
from books;
-- ์ฑ
์ ๋ชฉ์, ๋งจ ์๋ถํฐ 10๊น์ง๋ง ๊ฐ์ ธ์ค๊ณ , ๋ค์๋ ...์ ๋ถ์ฌ์ฃผ์ธ์
-- The Namesa...
select concat(substring(title,1,10),'...') as title
from books ;
replace
-- ๋ฌธ์์ด์ ๋ด์ฉ์ ๋ฐ๊พธ๋ ํจ์. replace()
-- ์ฑ
์ ๋ชฉ์, The๊ฐ ์์ผ๋ฉด, Hello๋ก ๋ฐ๊พธ๊ณ ์ถ๋ค.
select replace(title,'The','Hello')
from books;
select replace(title,' ','->')
from books;
upper/lower
-- ๋๋ฌธ์ / ์๋ฌธ์ ๋ณํํจ์ upper() / lower()
select replace(lower(title),'the','Hello') as title
from books;
select replace(upper(title),'the','Hello') as title
from books;
'MySQL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
MySQL) ๋ ๊ฐ์ ํ ์ด๋ธ ์กฐ์ธํ๊ธฐ (2) | 2024.05.16 |
---|---|
MySQL) ๋ฐ์ดํฐ๋ฒ ์ด์ค DATE(๋ ์ง) ๊ฐ๊ณตํ๋ ํจ์ (0) | 2024.05.16 |
MySQL) Reverse, Char_length, Ifnull ํจ์ ์ฌ์ฉํ๊ธฐ (0) | 2024.05.14 |
MySQL) LIKE, CASE, IF, GROUP BY ๊ตฌ๋ฌธ ์ฌ์ฉํ๊ธฐ (0) | 2024.05.14 |
MySQL) ์๋ธ์ฟผ๋ฆฌ(Sub Query)์ Concat, Max, Min, Avg ํจ์ ์ฌ์ฉํ๊ธฐ (0) | 2024.05.14 |