๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Data Base/MySQL

[MySQL] ์†์œผ๋กœ ๋ช…๋ น์–ด ์“ฐ๊ธฐ

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 2. 8.
๋ฐ˜์‘ํ˜•

์กฐ๊ฑด) PK๋Š” SEQ_ID

 

๋ฌธ์ œ 1) ์„œ์šธํŠน๋ณ„์‹œ์— ์‚ฌ๋Š” ์‚ฌ๋žŒ์˜ ๋ฐ์ดํ„ฐ ์กฐํšŒ

A)

mysql> select * from Address where Address1 = '์„œ์šธํŠน๋ณ„์‹œ';

(' ' ์ ๋Š”๊ฑฐ ๊ผญ ์žŠ์ง€๋ง๊ฒƒ)

(select * from ํ…Œ์ด๋ธ”์ด๋ฆ„ : ํ…Œ์ด๋ธ”์˜ ์ „์ฒด ๋‚ด์šฉ์ด ์„ ํƒ๋จ)

โ€‹

โ€‹

๋ฌธ์ œ 2) ๊ฒฝ๊ธฐ๋„์— ์‚ฌ๋Š” ์‚ฌ๋žŒ์˜ Client_ID ์กฐํšŒ

A)

mysql> select Client_ID fromโ€‹ Address where Address1 = '๊ฒฝ๊ธฐ๋„';

โ€‹

 

๋ฌธ์ œ 3) SEQ_ID๊ฐ€ 3 ์ด์ƒ์ธ ๋ฐ์ดํ„ฐ์˜ ์ฃผ์†Œ๋งŒ ์กฐํšŒ

A)

mysql> select Address1, Address2, Address3 from Address where SEQ_ID >= 3;

โ€‹

โ€‹

๋ฌธ์ œ 4) + ๋ฐ‘ ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€

A)

mysql> insert into Address values(6, '๊ฒฝ์ƒ๋ถ๋„', '๊ฒฝ์‚ฐ์‹œ', 'S์•„ํŒŒํŠธ', 70012, 523);

(PK๋‚˜ ์ˆซ์ž์—” ' ' ์•ˆ๋„ฃ์–ด๋„๋จ)

(INSERT๋ฌธ์—์„  ๊ด„ํ˜ธ ํ•„์ˆ˜!)

โ€‹

โ€‹

๋ฌธ์ œ 5-1) + ๋ฐ‘ ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€

A)

mysql> insert into Address(SEQ_ID, Address1, Client_ID) values(7, '๋Œ€๊ตฌ๊ด‘์—ญ์‹œ', 550);

โ€‹

โ€‹

๋ฌธ์ œ 5-2) ์œ„ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ‘๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜์‹œ์˜ค

A)

mysql> update Address set Address2 = '๋‹ฌ์„œ๊ตฌ', Address3 = '๋กฏ๋ฐ์‹œ๋„ค๋งˆ' where Client_ID = '550';โ€‹

(๋งŒ์ผ PK๋กœ๋งŒ ์ž…๋ ฅํ•˜๋ผ๋Š” ์กฐ๊ฑด์ด ๋‹ฌ๋ฆฌ๋ฉด ๋ฐ‘์ค„์นœ Client_ID='550' ๋ถ€๋ถ„์„ SEQ_ID๋กœ ์ž…๋ ฅ)

โ€‹

โ€‹

๋ฌธ์ œ 6) Client_ID๊ฐ€ 300 ์ดํ•˜์ธ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜์‹œ์˜ค

A)

mysql> delect from Address where Client_ID <= 300;

โ€‹

โ€‹

๋ฌธ์ œ 7) Address1์ด ์„œ์šธํŠน๋ณ„์‹œ ๋˜๋Š” ๊ฒฝ๊ธฐ๋„์ธ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜์‹œ์˜ค

A)

mysql> delect from Address where Address1 = '์„œ์šธํŠน๋ณ„์‹œ' or โ€‹Address1 = '๊ฒฝ๊ธฐ๋„';

๋ฐ˜์‘ํ˜•

'Data Base > MySQL' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

MySQL 9๋ฒˆ์งธ ์ˆ˜์—…  (0) 2021.02.08
MySQL 8๋ฒˆ์งธ์ˆ˜์—…  (0) 2021.02.08
MySQL 6๋ฒˆ์งธ์ˆ˜์—…  (0) 2021.02.07
MySQL 5๋ฒˆ์งธ์ˆ˜์—…  (0) 2021.02.07
MySQL 4๋ฒˆ์งธ์ˆ˜์—…  (0) 2021.02.07

๋Œ“๊ธ€