use zerobase;
create table person
(
id int,
name varchar(16),
age int,
sex CHAR
);
desc person;
insert into person (id, name, age, sex)
values (1, '이효리', 43, 'F');
insert into person
values (2, '이상순', 48, 'M');
select name, age, sex from person;
select *
from person;
select * from person where sex='F';
UPDATE person SET age=23 WHERE name='이효리';
DELETE FROM person WHERE name='이상순';
SELECT 문에서 데이터를 특정 컬럼을 기준으로 오름차순 혹은 내림차순 정렬하여 조회
실습 테이블 생성
CREATE TABLE celeb
(
ID int NOT NULL AUTO_INCREMENT PRIMARY KEY,
NAME varchar(32) NOT NULL DEFAULT '',
BIRTHDAY date,
AGE int,
SEX char(1),
JOB_TITLE varchar(32),
AGENCY varchar(32)
);
DESC celab;
INSERT INTO celeb VALUES (1, '아이유', '1993-05-16', 29, 'F', '가수, 텔런트', 'EDAM엔터테이먼트');
INSERT INTO celeb VALUES (2, '이미주', '1994-09-23', 28, 'F', '가수', '울림엔터테이먼트');
INSERT INTO celeb VALUES (3, '송강', '1994-04-23', 28, 'M', '텔런트', '나무엑터스');
INSERT INTO celeb VALUES (4, '강동원', '1981-01-18', 41, 'M', '영화배우, 텔런트', 'YG엔터테이먼트');
INSERT INTO celeb VALUES (5, '유재석', '1972-08-14', 50, 'M', 'MC, 개그맨', '안테나');
INSERT INTO celeb VALUES (6, '차승원', '1970-06-07', 48, 'M', '영화배우, 모델', 'YG엔터테이먼트');
INSERT INTO celeb VALUES (7, '이수현', '1999-05-04', 23, 'F', '가수', 'YG엔터테이먼트');
select * from celeb;
select age, name
from celeb
order by age asc;
select age, name
from celeb
order by age desc;
select age, name
from celeb
order by age, name;
select age, name
form celeb
order by age desc, name asc;