๐Ÿ—ƒ SQL ๋ฌธ๋ฒ• - select, where

์€์œ ๋กœ๊ทธยท2021๋…„ 10์›” 8์ผ
0

๐Ÿ“š study

๋ชฉ๋ก ๋ณด๊ธฐ
3/21

SELECT

SELECT ์ปฌ๋Ÿผ๋ช… FROM ํ…Œ์ด๋ธ”๋ช…;
ํŠน์ • ํ…Œ์ด๋ธ”์—์„œ ์ปฌ๋Ÿผ ์กฐํšŒ

SELECT * FROM ํ…Œ์ด๋ธ”๋ช…;
ํŠน์ • ํ…Œ์ด๋ธ”์—์„œ ์ „์ฒด ์กฐํšŒ

SELECT ์ปฌ๋Ÿผ๋ช… DISTINCT FROM ํ…Œ์ด๋ธ”๋ช…;
ํŠน์ • ํ…Œ์ด๋ธ”์—์„œ ์ปฌ๋Ÿผ์˜ ์ค‘๋ณต ์ œ๊ฑฐ ํ›„ ์กฐํšŒ


WHERE

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์กฐ๊ฑด;
ํŠน์ • ํ…Œ์ด๋ธ”์—์„œ ์กฐ๊ฑด์— ๋งž๋Š” ๊ฒƒ๋งŒ ์กฐํšŒ

์—ฐ์‚ฐ์ž ์ข…๋ฅ˜
์‚ฐ์ˆ  ์—ฐ์‚ฐ์ž( ), *, /, +, - ์ˆœ์œผ๋กœ ์šฐ์„  ์ˆœ์œ„ ๊ฒฐ์ •
๋น„๊ต ์—ฐ์‚ฐ์ž=, <>, !=, <, >
๋…ผ๋ฆฌ ์—ฐ์‚ฐ์žNOT, AND, OR
SQL ์—ฐ์‚ฐ์žIN, BETWEEN, IS NULL, LIKE, EXISTS ๋“ฑ
์ง‘ํ•ฉ ์—ฐ์‚ฐ์žUNION ALL, UNION, INTERSECT, MINUS

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์ปฌ๋Ÿผ BETWEEN ์ˆซ์ž1(์•ŒํŒŒ๋ฒณ1) AND ์ˆซ์ž2(์•ŒํŒŒ๋ฒณ2);
ํŠน์ • ํ…Œ์ด๋ธ”์—์„œ ์ปฌ๋Ÿผ์ด ์ˆซ์ž1(์•ŒํŒŒ๋ฒณ1)์™€ ์ˆซ์ž2(์•ŒํŒŒ๋ฒณ2) ์‚ฌ์ด์— ์žˆ๋Š” ๊ฒƒ๋“ค๋งŒ ์กฐํšŒ

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์ปฌ๋Ÿผ LIKE '์กฐ๊ฑด';

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์ปฌ๋Ÿผ IN (์ˆซ์ž1, ์ˆซ์ž2);
ํŠน์ • ํ…Œ์ด๋ธ”์—์„œ ์ปฌ๋Ÿผ์ด ์ˆซ์ž1(์•ŒํŒŒ๋ฒณ1)์™€ ์ˆซ์ž2(์•ŒํŒŒ๋ฒณ2) ์‚ฌ์ด์— ์žˆ๋Š” ๊ฒƒ๋“ค๋งŒ ์กฐํšŒ

profile
เน‘โ€ขโ€ฟโ€ขเน‘

0๊ฐœ์˜ ๋Œ“๊ธ€