๐Ÿ—ƒ SQL ๋ฌธ๋ฒ• - select, distinct, order by

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

๐Ÿ“š study

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

mysql ๊ธฐ์ค€์œผ๋กœ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค เน‘'ูฎ'เน‘

SELECT ์ปฌ๋Ÿผ๋ช…1, ์ปฌ๋Ÿผ๋ช…2 FROM ํ…Œ์ด๋ธ”๋ช…;

์ปฌ๋Ÿผ1๊ณผ ์ปฌ๋Ÿผ2 ์กฐํšŒ

SELECT * FROM ํ…Œ์ด๋ธ”๋ช…;

์ „์ฒด ๋ฐ์ดํ„ฐ ์กฐํšŒ

SELECT DISTINCT ์ปฌ๋Ÿผ๋ช…1 FROM ํ…Œ์ด๋ธ”๋ช…;

์ค‘๋ณต๋˜์ง€ ์•Š๋Š” ์œ ์ผํ•œ ๋ฐ์ดํ„ฐ ์กฐํšŒ

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… WHERE ์กฐ๊ฑด;

์กฐ๊ฑด์— ๋งž๋Š” ๋ฐ์ดํ„ฐ ์กฐํšŒ

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… ORDER BY ์ปฌ๋Ÿผ๋ช…1 ASC;

์ปฌ๋Ÿผ๋ช…1์˜ ์˜ค๋ฆ„์ฐจ์ˆœ๋Œ€๋กœ ๋ฐ์ดํ„ฐ ์ „์ฒด ์กฐํšŒ
โžก๏ธ (์˜ค๋ฆ„์ฐจ์ˆœ์€ ๋ณดํ†ต ORDER BY ~ ASC๋ฅผ ์ž‘์„ฑํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค)

SELECT * FROM ํ…Œ์ด๋ธ”๋ช… ORDER BY ์ปฌ๋Ÿผ๋ช…1 DESC;

์ปฌ๋Ÿผ๋ช…1์˜ ๋‚ด๋ฆผ์ฐจ์ˆœ๋Œ€๋กœ ๋ฐ์ดํ„ฐ ์ „์ฒด ์กฐํšŒ

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

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