Notice
Recent Posts
Recent Comments
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Tags more
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

๐ŸŒฒ์ž๋ผ๋‚˜๋Š”์ฒญ๋…„

MySQL ๊ณต๋ถ€5(IN, BETWWEN) ๋ณธ๋ฌธ

DataBase

MySQL ๊ณต๋ถ€5(IN, BETWWEN)

JihyunLee 2019. 5. 3. 12:06
๋ฐ˜์‘ํ˜•

IN

The IN operator allows you to specify multiple values in a WHERE clause.

The IN operator is a shorthand for multiple OR conditions.

customer ํ…Œ์ด๋ธ”์—์„œ ๋‚˜๋ผ ์ด๋ฆ„์ด UK, Germany ์ธ๊ฒƒ ๊ณ ๋ฅด๊ธฐ

SELECT * FROM Customer WHERE Country IN ('Germany', 'UK');

customer ํ…Œ์ด๋ธ”์—์„œ ๋‚˜๋ผ ์ด๋ฆ„์ด UK, Germany ๊ฐ€ ์•„๋‹Œ๊ฒƒ ๊ณ ๋ฅด๊ธฐ

SELECT * FROM Customer WHERE Country NOT IN ('Germany', 'UK');

supplier์˜ ๋‚˜๋ผ์™€ ๊ฐ™์€ ๋‚˜๋ผ์— ์‚ฌ๋Š” ๊ณ ๊ฐ ๊ณ ๋ฅด๊ธฐ

SELECT * FROM Customer WHERE Country IN (SELECT Country FROM Suppliers);

 

BETWEEN

The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates.

The BETWEEN operator is inclusive: begin and end values are included. 

product ํ…Œ์ด๋ธ”์—์„œ ๊ฐ€๊ฒฉ์ด 10 ์ด์ƒ 20 ์ดํ•˜์ธ๊ฒƒ ๊ณ ๋ฅด๊ธฐ

SELECT * FROM Product
WHERE Price BETWEEN 10 AND 20

product ํ…Œ์ด๋ธ”์—์„œ ๊ฐ€๊ฒฉ์ด 10 ์ด์ƒ 20 ์ดํ•˜๊ฐ€ ์•„๋‹Œ๊ฒƒ ๊ณ ๋ฅด๊ธฐ

-> NOT BETWEEN

๋‚ ์งœ, ๋ฌธ์ž์—ด๋„ ๊ฐ€๋Šฅ

 

 

 

 

๋ฐ˜์‘ํ˜•

'DataBase' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

MySQL ๊ณต๋ถ€4(LIMIT, MIN, MAX, COUNT, AVG, SUM)  (0) 2019.05.03
My SQL ๊ณต๋ถ€ 3(UPDATE, DELETE)  (0) 2019.05.02
My SQL ๊ณต๋ถ€ 2(ORDER, INSERT, NULL)  (0) 2019.05.02
My SQL ๊ณต๋ถ€1(SLEECT, FROM, WHERE)  (0) 2019.05.02