728x90
INSERT INTO books (title, author_fname, author_lname, released_year, stock_quantity, pages)
VALUES
('The Namesake', 'Jhumpa', 'Lahiri', 2003, 32, 291),
('Norse Mythology', 'Neil', 'Gaiman',2016, 43, 304),
('American Gods', 'Neil', 'Gaiman', 2001, 12, 465),
('Interpreter of Maladies', 'Jhumpa', 'Lahiri', 1996, 97, 198),
('A Hologram for the King: A Novel', 'Dave', 'Eggers', 2012, 154, 352),
('The Circle', 'Dave', 'Eggers', 2013, 26, 504),
('The Amazing Adventures of Kavalier & Clay', 'Michael', 'Chabon', 2000, 68, 634),
('Just Kids', 'Patti', 'Smith', 2010, 55, 304),
('A Heartbreaking Work of Staggering Genius', 'Dave', 'Eggers', 2001, 104, 437),
('Coraline', 'Neil', 'Gaiman', 2003, 100, 208),
('What We Talk About When We Talk About Love: Stories', 'Raymond', 'Carver', 1981, 23, 176),
("Where I'm Calling From: Selected Stories", 'Raymond', 'Carver', 1989, 12, 526),
('White Noise', 'Don', 'DeLillo', 1985, 49, 320),
('Cannery Row', 'John', 'Steinbeck', 1945, 95, 181),
('Oblivion: Stories', 'David', 'Foster Wallace', 2004, 172, 329),
('Consider the Lobster', 'David', 'Foster Wallace', 2005, 92, 343),
('10% Happier', 'Dan', 'Harris', 2014, 29, 256),
('fake_book', 'Freida', 'Harris', 2001, 287, 428),
('Lincoln In the Bardo', 'George', 'Saunders', 2017, 156, 375);
-- 문자열의 일부분만 가져오는 함수 substring()
-- 책 제목을 첫글자부터 10번째까지만 가져오기.
-- substring 함수의 시작위치는 0이아닌 1부터 시작된다!!!
-- substring 함수의 시작위치는 0이아닌 1부터 시작된다!!!
select substring( title, 1,10 ) as title
from books;
-- 타이틀 컬럼의 내용을, 맨 뒤에서 5번째 글자부터 끝까지 가져오시오.
select substring( title, -5) as title
from books;
-- 타이틀을 가져오되, 5번째 글자부터 15번째 글자까지 가져오시오.
select substring(title,5,15) as title
from books;
'MySQL' 카테고리의 다른 글
MySQL - char_length( ) / 문자열 길이 구하는 함수 (0) | 2022.12.06 |
---|---|
MySQL - 문자열을 다른 문자열로 바꾸는 함수 replace() 문자열을 뒤집는 함수 reverse() (0) | 2022.12.06 |
MySQL - concat(),concat_ws(),as / 두개의 컬럼 합치기, 컬럼이름 변경해서 출력 (0) | 2022.12.06 |
MySQL - CRUD 실습 문제 풀이 (0) | 2022.12.06 |
MySQL - CRUD (Create, Read, Update, Delete / 데이터를 생성, 읽기, 갱신, 삭제) (0) | 2022.12.06 |