2021. 10. 14. 14:34ใ๋ฐ์ดํฐ๋ฒ ์ด์ค
์ ๋ง ๊ธฐ์ด์ ์ธ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ช ๋ น์ด๋ฅผ ์ ๋ฆฌํด๋ดค๋ค.
1. select
select ํ๋๋ช form ํ ์ด๋ธ๋ช ;
์ด ํ์์ด ๊ธฐ๋ณธ์ด๋ค.
ex) select * from tb_customer;
ํ๋ฉด tb_customer ํ ์ด๋ธ์ ์ ์ฒด๋ฅผ ๋ณด์ฌ์ค๋ค.
select ํ๋๋ช as '๋ณ๋ช ' form ํ ์ด๋ธ๋ช ;
ํ๋ฉด ํ๋๋ช ์ '๋ณ๋ช '์ผ๋ก ๋ฐ๊ฟ์ ๋ํ๋ผ ์ ์๋ค.
์ด๋ ๋ณ๋ช ์ ๊ณต๋ฐฑ์ ํฌํจํ๋ค๋ฉด ๋ฐ์ดํ๋ฅผ ์ฌ์ฉํด์ค์ผํ๋ค.
2. where
select ํ๋๋ช from ํ ์ด๋ธ๋ช where ์กฐ๊ฑด;
3. and
select ํ๋๋ช from ํ ์ด๋ธ๋ช where ์กฐ๊ฑด1 and ์กฐ๊ฑด2 ...;
4. or
select ํ๋๋ช from ํ ์ด๋ธ๋ช where ์กฐ๊ฑด1 or ์กฐ๊ฑด2 ...;
* and , or ํผํฉ
5. between A and B..
select ํ๋๋ช from ํ ์ด๋ธ๋ช where ํ๋๋ช between a and b..;
* total_point 10000๋ฏธ๋ง ์ด๊ฑฐ๋ 30000์ด์
6. ๋น๊ต์ฐ์ฐ์
= ๊ฐ๋ค.
<>, != , ^= ๊ฐ์ง์๋ค.
A > B
A < B
A >= B
A <= B
7. LIKE
๋ฌธ์% ๋ฌธ์๋ก ์์ํ๋ ๊ฐ
%๋ฌธ์ ๋ฌธ์๋ก ๋๋๋ ๊ฐ
%๋ฌธ์% ๋ฌธ์๊ฐ ํฌํจ๋ ๊ฐ
_ ์ง์ ๋ ์์น์ 1์๋ฆฌ
* PHONE_NUMBER๊ฐ '___-____-____' ํ์์ด ์๋ ํ์ ๊ณ ๊ฐ ๊ฒ์ฌ
8. IN
SELECT ํ๋๋ช FROM ํ ์ด๋ธ๋ช WHERE ํ๋๋ช IN (๊ฒ์๊ฐ1, ๊ฒ์๊ฐ2 ...);
9. order by
select ํ๋๋ช from ํ ์ด๋ธ๋ช where ์กฐ๊ฑด order by ํ๋๋ช desc | asc ;