๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์ „์ฒด ๊ธ€111

[Database] HeidiSQL ๊ทธ๋ฃน ํ•จ์ˆ˜ (์ง‘ํ•ฉ ํ•จ์ˆ˜) ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์„ธ๊ณ„๋ฅผ ํƒ๊ตฌํ•ฉ์‹œ๋‹ค. [ ๊ทธ๋ฃน ํ•จ์ˆ˜ ] - count() : ํ–‰์˜ ๊ฐฏ์ˆ˜ - avg() : ํ‰๊ท  - max() : ์ตœ๋Œ€๊ฐ’ - min() : ์ตœ์†Œ๊ฐ’ - sum() : ํ•ฉ๊ณ„ -- ์ผ๋ฐ˜ ์กฐ๊ฑด : Where์ ˆ ์‚ฌ์šฉ -- ๊ทธ๋ฃน์— ๋Œ€ํ•œ ์กฐ๊ฑด : Group By ~ Having ์ ˆ ์‚ฌ์šฉ -- Group By ์ ˆ : ๊ทธ๋ฃน์œผ๋กœ ๋ฌถ๊ณ ์ž ํ•˜๋Š” ์ปฌ๋Ÿผ๋ช… or ์ผ๋ฐ˜ํ•จ์ˆ˜๋ฅผ ์ฒ˜๋ฆฌํ•œ ์ปฌ๋Ÿผ ์ง€์ • -- Having์ ˆ -- : ๊ทธ๋ฃนํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•œ ์กฐ๊ฑด(๋น„๊ต ์—ฐ์‚ฐ์ž) ์‚ฌ์šฉ -- : ๊ทธ๋ฃน ์กฐ๊ฑด์ด ์—†์œผ๋ฉด Having์ ˆ์€ ์‚ฌ์šฉ ์•ˆ ํ•ด๋„ ๋จ -- (Group By ์ ˆ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ) -- ๊ทธ๋ฃน์— ๋Œ€ํ•œ ๋ฌธ์ œ๋กœ ์ธ์‹ํ•˜๋Š” ๋ฐฉ๋ฒ• -- : ~๋ณ„๋กœ ์กฐํšŒ ๋ผ๋Š” ๊ฐœ๋…์  ์šฉ์–ด๊ฐ€ ์‚ฌ์šฉ๋˜๋ฉด Group By๋ฅผ ์‚ฌ์šฉ 1. Select 2. FROM ํ…Œ์ด๋ธ” 3. WHE.. 2023. 11. 27.
[Database] Heidi SQL ๋ฌธ์ž์—ดํ•จ์ˆ˜, ๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜, ๊ณต๋ฐฑ ์ œ๊ฑฐ, ํŠน์ • ์ž๋ฆฟ์ˆ˜๊นŒ์ง€์˜ ๋ฌธ์ž, ๋ฌธ์ž์—ด ๋‚ด ์œ„์น˜ ๊ฐ’, ์„œ๋ธŒ์ฟผ๋ฆฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์„ธ๊ณ„๋ฅผ ํƒ๊ตฌํ•ฉ์‹œ๋‹ค. [ ๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜ ] ๋Œ€๋ฌธ์ž : Upper ์†Œ๋ฌธ์ž : Lower [ ์ž‘์„ฑ ์ฝ”๋“œ ] SELECT LOWER(mem_id) AS '์†Œ๋ฌธ์ž๋กœ', UPPER(mem_id) AS '๋Œ€๋ฌธ์ž๋กœ' FROM member; [ ๊ฒฐ๊ณผ ] [ ๊ณต๋ฐฑ ์ œ๊ฑฐํ•˜๊ธฐ ] LTRIM : ์™ผ์ชฝ ๊ณต๋ฐฑ ์ œ๊ฑฐ RTRIM : ์˜ค๋ฅธ์ชฝ ๊ณต๋ฐฑ ์ œ๊ฑฐ TRIM : ์ขŒ์šฐ ๊ณต๋ฐฑ ์ œ๊ฑฐ [ ์ž‘์„ฑ ์ฝ”๋“œ ] SELECT ' ์™ผ์ชฝ๊ณต๋ฐฑ', LTRIM(' ์™ผ์ชฝ๊ณต๋ฐฑ์ œ๊ฑฐ'), '์˜ค๋ฅธ์ชฝ๊ณต๋ฐฑ ', RTRIM('์˜ค๋ฅธ์ชฝ ๊ณต๋ฐฑ์ œ๊ฑฐ '), ' ์ขŒ์šฐ ๊ณต๋ฐฑ ',TRIM(' ์ขŒ์šฐ ๊ณต๋ฐฑ ') ; [ ๊ฒฐ๊ณผ ] [ ํŠน์ • ์ž๋ฆฟ์ˆ˜๊นŒ์ง€์˜ ๋ฌธ์ž ์ถ”์ถœํ•˜๊ธฐ ] - mysql or mariaDB์šฉ Left, Right [ ์ž‘์„ฑ ์ฝ”๋“œ ] -- ํŠน์ • ์ž๋ฆฟ์ˆ˜๊นŒ์ง€์˜ ๋ฌธ์ž ์ถ”์ถœํ•˜๊ธฐ --.. 2023. 11. 26.
[Database] HeidiSQL ํ•จ์ˆ˜ In, Replace, Select, nvl, ๋‚ ์งœ ํ•จ์ˆ˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์„ธ๊ณ„๋ฅผ ํƒ๊ตฌํ•ฉ์‹œ๋‹ค. [ ์กฐ๊ฑด ] -- [๋ฌธ์ œ] -- ์ƒํ’ˆ๋ถ„๋ฅ˜๋ช…์— ์ปดํ“จํ„ฐ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๊ณ , -- ์ฃผ๋ฌธ์ด๋ ฅ์ด ์žˆ๋Š” ์ƒํ’ˆ์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. -- ์ƒํ’ˆ๋ช…, ์ƒํ’ˆ๋ถ„๋ฅ˜๋ช… ์กฐํšŒํ•˜๊ธฐ [ ์ž‘์„ฑ ์ฝ”๋“œ ] SELECT Prod_name, (select Lprod_nm FROM lprod WHERE lprod_gu=prod_lgu) AS lprod_nm FROM prod WHERE prod_lgu IN (SELECT lprod_gu FROM lprod WHERE lprod_nm LIKE '%์ปดํ“จํ„ฐ%') AND prod_id IN (SELECT cart_prod FROM cart); [ ๊ฒฐ๊ณผ ] 1. Replace ํ•จ์ˆ˜ ์น˜ํ™˜ํ•˜๊ธฐ replace(์›๋ณธ๊ฐ’, ์ฐพ์„ ๊ฐ’, ๋ฐ”๊ฟ€ ๊ฐ’) [ ํ™œ์šฉ ์˜ˆ์‹œ ] -- R.. 2023. 11. 25.
[Database] Heidi SQL ๋ฌธ์ž์—ดํ•จ์ˆ˜, Select, From, Where, ๋ณ„์นญ ์‚ฌ์šฉ, ์ •๋ ฌ, ์—ฐ์‚ฐ์ž, ๋‚ ์งœ ํ˜•์‹, ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ์ˆœ์„œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์„ธ๊ณ„๋ฅผ ํƒ๊ตฌํ•ฉ์‹œ๋‹ค. ํšŒ์› ํ…Œ์ด๋ธ” ์ „์ฒด ์กฐํšŒํ•˜๊ธฐ SELECT * FROM member; ๋ณ„์นญ์„ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ  ๊ธด ๋‹จ์–ด๋ฅผ ์ค„์—ฌ์„œ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ์ข‹๋‹ค. SQL์—์„œ ๋ณ„์นญ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ณณ - ์ปฌ๋Ÿผ๋ช… ๋Œ€์‹  ๋ณ„์นญ ์‚ฌ์šฉ ์˜ˆ์‹œ) mem_id as id - ํ…Œ์ด๋ธ”๋ช… ๋Œ€์‹  ๋ณ„์นญ ์‚ฌ์šฉ ์˜ˆ์‹œ) From member mem -- ํšŒ์›์˜ ๋งˆ์ผ๋ฆฌ์ง€ ๊ฐ’์ด 10 ์ด์ƒ์ธ ๋ฐ์ดํ„ฐ๋งŒ ์กฐํšŒํ•˜๊ธฐ -- ์กฐํšŒ์ปฌ๋Ÿผ์€ ํšŒ์›์•„์ด๋””, ํšŒ์›์ด๋ฆ„, ๋งˆ์ผ๋ฆฌ์ง€ -- ๋ณ„์นญ, id, name, point -- ์‚ฌ์šฉํ•  ํ…Œ์ด๋ธ”๋ช… : member -- ์‚ฌ์šฉํ•  ์ปฌ๋Ÿผ๋ช… : mem_mileage, mem_id, mem_name -- ์กฐ๊ฑด์ด ๋ฌด์—‡์ธ์ง€ : mem_mileage >= 10 SELECT mem_mileage AS point, mem_id AS id, me.. 2023. 11. 24.

loading