728x90
[교재 SQL 스크립트] 실전_ch1-2-1-member_info.sql
use mydb;
CREATE TABLE member_info (
member_no INT,
name VARCHAR(10),
gender VARCHAR(1)
);
INSERT INTO member_info
VALUES (10, '이장현', 'M');
INSERT INTO member_info
VALUES (20, '유길채', 'F');
INSERT INTO member_info
VALUES (30, '남연준', 'M');
INSERT INTO member_info
VALUES (40, '경은애', 'F');
INSERT INTO member_info
VALUES (50, '량음', 'M');
COMMIT;
SELECT name,
CASE member_info.gender
WHEN 'F' THEN '여자'
WHEN 'M' THEN '남자'
END AS gender
FROM member_info;
SELECT name,
IF(gender = 'F', '여자', '남자') AS gender
FROM member_info;
728x90
'MySQL' 카테고리의 다른 글
내일은 SQL(응용 실전편) 실전_ch1-1-3-departments&employees.sql (0) | 2024.05.20 |
---|---|
내일은 SQL(응용 실전편) 실전_ch1-1-2-product&payment.sql (0) | 2024.05.20 |
내일은 SQL(응용 실전편) 실전_ch1-1-1-student&winner_list.sql (0) | 2024.05.20 |
(Workbench) SSH 터널링으로 DB서버 접속(pem키가 있을 때) (2) | 2022.03.16 |
Dbeaver에서 로컬DB에 접속 못하는 현상 해결 (0) | 2022.02.11 |