๐Ÿ’ป [SQL] 6. ๋‚ด์žฅํ˜• ํ•จ์ˆ˜ - ๋ฌธ์ž์—ด ํ•จ์ˆ˜

thisk336ยท2023๋…„ 10์›” 4์ผ
0

SQL

๋ชฉ๋ก ๋ณด๊ธฐ
6/17
post-thumbnail

๋‚ด์žฅํ˜• ํ•จ์ˆ˜

  • ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋Š” SQL์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋‚ด์žฅํ˜• ํ•จ์ˆ˜๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
  • ๋‚ด์žฅํ˜• ํ•จ์ˆ˜๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ ์‹œ์Šคํ…œ ๋ฒค๋”๋ณ„๋กœ ์•ฝ๊ฐ„์˜ ์ฐจ์ด๊ฐ€ ์žˆ์ง€๋งŒ, ๊ฑฐ์˜ ๋น„์Šทํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
  • ๋‚ด์žฅํ˜• ํ•จ์ˆ˜๋กœ๋Š” ๋ฌธ์ž์—ด ๋ฐ ์ˆซ์žํ˜• ํ•จ์ˆ˜, ๋‚ ์งœํ˜• ํ•จ์ˆ˜ ๊ทธ๋ฆฌ๊ณ  ํ˜•๋ณ€ํ™˜ ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

๋ฌธ์ž์—ด ํ•จ์ˆ˜

๋ฌธ์ž์—ด ํ•จ์ˆ˜์„ค๋ช…
LOCATE(ํŠน์ • ๋ฌธ์ž,๋ฌธ์ž์—ด)๋ฌธ์ž์—ด์—์„œ ํŠน์ •๋ฌธ์ž๊ฐ€ ๋ช‡ ๋ฒˆ์งธ์— ์œ„์น˜ํ•ด ์žˆ๋Š”์ง€๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
SUBSTRING(๋ฌธ์ž์—ด,m)๋ฌธ์ž์—ด์—์„œ m๋ฒˆ์งธ ๋ฌธ์ž๋ถ€ํ„ฐ ๋ฐ˜ํ™˜
RIGHT(๋ฌธ์ž์—ด,m)๋ฌธ์ž์—ด์˜ ์˜ค๋ฅธ์ชฝ๋ถ€ํ„ฐ m๋ฒˆ์งธ ๋ฌธ์ž๊นŒ์ง€ ๋ฐ˜ํ™˜
LEFT(๋ฌธ์ž์—ด,m)๋ฌธ์ž์—ด์˜ ์™ผ์ชฝ๋ถ€ํ„ฐ m๋ฒˆ์งธ ๋ฌธ์ž๊นŒ์ง€ ๋ฐ˜ํ™˜
UPPER(๋ฌธ์ž์—ด)๋ฌธ์ž์—ด์„ ๋Œ€๋ฌธ์ž๋กœ ๋ฐ”๊ฟ”์„œ ๋ฐ˜ํ™˜
LOWER(๋ฌธ์ž์—ด)๋ฌธ์ž์—ด์„ ์†Œ๋ฌธ์ž๋กœ ๋ฐ”๊ฟ”์„œ ๋ฐ˜ํ™˜
LENGTH(๋ฌธ์ž์—ด)๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ๋ฐ˜ํ™˜
CONCAT(๋ฌธ์ž์—ด1, ๋ฌธ์ž์—ด2)๋ฌธ์ž์—ด1๊ณผ ๋ฌธ์ž์—ด2๋ฅผ ํ•ฉ์ณ์„œ ๋ฐ˜ํ™˜
REPLACE(๋ฌธ์ž์—ด,m,n)๋ฌธ์ž์—ด์˜ m์„ n์œผ๋กœ ๋ฐ”๊ฟ”์„œ ๋ฐ˜ํ™˜
SELECT LOCATE("t","string"), SUBSTRING("string",3), RIGHT("string",3), LEFT("string",3),
	   UPPER("string"), LOWER("STRING");
SELECT LENGTH("string"), CONCAT("Hello", "World!"), REPLACE("string","t","n");


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