7. 유니온(union)
유니온(union) 합집합을 나타내는 연산자로, 중복된 값을 제거함 서로 같은 종류의 테이블(컬럼이 같아야 함)에서만 적용이 가능 select 컬럼명, 컬럼명2, ... 테이블1 union select 컬럼명1, 컬럼명2.. from 테이블2 create table product( code varchar(6) not null, name varchar(50) not null, detail varchar(1000), price int default 0, regdate datetime default now() ); insert into product values('100000', '아이폰14', '이뻐요', 1500000 , now()); insert into product values('100001', '갤..
6. join
# 프로필 테이블 생성 create table profile( userid varchar(20) not null, height double, weight double, blood varchar(10), mbti varchar(10), foreign key(userid) references member(userid) ); insert into profile values('apple', 160, 50, 'A형', 'ISTP'); insert into profile values('banana', 155, 55, 'B형', 'ISTP'); insert into profile values('grapes', 170, 80, 'AB형', 'ISTP'); insert into profile values('melon',..
5. 문자열 함수
MySQL 문자열 함수 concat 복수의 문자열을 연결해주는 함수 select concat(문자열1, 문자열2, ...); select concat('안녕', '하세요') as concat; 안녕하세요 select concat(address,' ', address2, ' ', address3) as address from member where username ='오렌지'; 서울시 서초구 양재동 아파트 101동 101호 left, right 왼쪽 또는 오른쪽에서 길이만큼 문자열을 가져옴 select left(문자열, 길이); select right(문자열, 길이); select left('ABCDEFGHIJKLMN', 5) as ENG; ABCDE # 원래 email = apple@apple.com s..