MySQL

    MySQL - 문자열을 다른 문자열로 바꾸는 함수 replace() 문자열을 뒤집는 함수 reverse()

    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..

    MySQL - substring() 문자열 일부분 가져오기

    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..

    MySQL - concat(),concat_ws(),as / 두개의 컬럼 합치기, 컬럼이름 변경해서 출력

    select * from books; 문자열을 합치는 함수 concat() , concat_ws() -- author_fname과 author_lname 컬럼의 값을 합해서 -- full_name이라고 보여주고싶다. -- concat() 함수를 이용하는 방법 select concat(author_fname,' ',author_lname) as full_name from books; -- concat_ws() 함수를 이용하는 방법 select concat_ws( ' ',author_fname ,author_lname) as full_name from books; 데이터를 가져온 후 컬럼명을 변경해주는 방법은 as 뒤에 컬럼명을 적어주면 된다.

    MySQL - CRUD 실습 문제 풀이

    이 글 이전에 포스팅한 CRUD로 실습 문제풀이를 하는 과정입니다. 1. 2. select article,color from shirts; 3. select article,color,shirt_size,last_worn from shirts where shirt_size='M'; 4. update shirts set shirt_size = 'L' where article = 'polo shirt'; 5. update shirts set last_worn = 0 where last_worn > 15; 6. update shirts set shirt_size = 'XS' , color = 'off white' where color = 'white'; 7. delete from shirts where last..