Remove or Trim First or Last Few Characters in MySQL Database with SQL ¿ì¼± Æ®¸²À» Á¦°ÅÇϰųª ¶Ç´Â SQL¿Í MySQL µ¥ÀÌÅͺ£À̽º¿¡¼ ¸¶Áö¸· ¸îÀÚ¸¦
Another useful string function in MySQL database is TRIM() which will return a text string after removing the matching leading or trailing characters, also known as prefixes or suffixes. MySQL µ¥ÀÌÅͺ£À̽º¿¡ ¶Ç ´Ù¸¥ À¯¿ëÇÑ ±â´ÉÀ» À߶󳻱⠹®ÀÚ¿ (¼ö)¿¡´Â ÀÏÄ¡ÇÏ´Â ¼±Çà ¶Ç´Â ÈÄÇà ¹®ÀÚ¸¦ Á¦°ÅÇÑ ÈÄ, Á¢µÎ»ç ȤÀº Á¢¹Ì»ç·Î ¾Ë·ÁÁø ¶ÇÇÑ ÅØ½ºÆ® ¹®ÀÚ¿À» ¹ÝȯÇÑ´Ù. It¡¯s been described by MySQL reference as function that returns the string str with all remstr prefixes or suffixes removed. ±×°ÍÀ» ÇÔ¼ö·Î MySQLÀ» ÂüÁ¶ remstr Á¢µÎ»ç ¶Ç´Â Á¢¹Ì»ç¿Í ¹ÝȯÇÏ´Â ¸ðµç ¹®ÀÚ¿ÀÇ Á¦°Å´Â str¿¡ ÀÇÇØ ¼³¸íµÇ°íÀÖ´Ù. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. ÁöÁ¤ÇÏ´Â °æ¿ì¿¡´Â µÑ ´Ù ¼±µµ ¶Ç´Â ÈÄÇà ¸ðµÎ¿¡°Ô ¾Æ¹« »ý°¢ÀÔ´Ï´Ù. remstr is optional and, if not specified, spaces are removed. remstrÀº ¿É¼ÇÀ̸ç, ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é °ø¹éÀÌ Á¦°ÅµË´Ï´Ù.
Syntax of TRIM(): ±¸¹® Àß¶ó³»±â () :
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str) Àß¶ó³»±â ([(µÑ´Ù | ´ëÇ¥ | ÈÄÇà) [remstr]]´Â str), Àß¶ó³»±â ([remstr]´Â str)
For example: ¿¹¸¦ µé¸é :
SELECT TRIM(¡¯ bar ¡®); ¼±Åà Àß¶ó³»±â ( '¹Ù');
will return ¡®bar¡¯ (spaces dropped). ¹Ýȯ '¹Ù'(°ø¹é) ¶³¾îÁø °ÍÀÔ´Ï´Ù.
SELECT TRIM(LEADING ¡®x¡¯ FROM ¡®xxxbarxxx¡¯); ¼±Åà Àß¶ó³»±â (´ëÇ¥ 'x'¸¦ 'xxxbarxxx');
will return ¡®barxxx¡¯ (only leading x characters is removed). 'barxxx'(´Ü ¼±µµ x ¹®ÀÚ¸¦ ¹ÝȯÇÕ´Ï´Ù)¸¦ Á¦°ÅÇÕ´Ï´Ù.
SELECT TRIM(BOTH ¡®x¡¯ FROM ¡®xxxbarxxx¡¯); ¼±Åà Àß¶ó³»±â (µÑ ´Ù 'x'¸¦ 'xxxbarxxx');
will return ¡®bar¡¯ (leading and trailing xs is dropped). ¹Ýȯ '¹Ù'(¼±µµÇϰí XSÀ» ¶³¾î¶ßÀÌ´Ù ÈÄÇà).
SELECT TRIM(TRAILING ¡®xyz¡¯ FROM ¡®barxxyz¡¯); ¼±Åà Àß¶ó³»±â (ÈÄÇà 'xyzÀÌ'¿¡¼ 'barxxyz');
will return ¡®barx¡¯ (trailing xyz is cleared). 'barx'(ÈÄÇà xyzÀÌ Áö¿öÁý´Ï´Ù)¸¦ ¹ÝȯÇÑ´Ù.
This function is multi-byte safe. ÀÌ ±â´ÉÀº ¸ÖƼ - ¾ÈÀü ¹ÙÀÌÆ®. And it can also be used with other SQL command such as UPDATE to perform modification update directly on database table data with SQL statements using tool such as phpMyAdmin. phpMyAdminÀº SQL ¹®À» Á÷Á¢ µîÀ¸·Î ¾÷µ¥ÀÌ Æ®¿Í °°Àº µµ±¸¸¦ »ç¿ëÇÏ¿© µ¥ÀÌÅͺ£À̽º Å×À̺íÀÇ µ¥ÀÌÅ͸¦ ¼öÁ¤ ¾÷µ¥ÀÌ Æ®¸¦ ¼öÇàÇϵµ·Ï ±×¸®°í ±×°ÍÀº ¶Ç ´Ù¸¥ SQL ¸í·É°ú ÇÔ²² »ç¿ëÇÏ½Ç ¼öÀÖ½À´Ï´Ù.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. Áß¿ä :ÀÌ ±â°è´Â "º¸Áõµµ¾øÀÌÀÖ´Â ±×´ë·Î"Á¦°øµË´Ï´Ù ÆäÀÌÁö¸¦ ¹ø¿ªÇß´Ù. Machine translation may be difficult to understand. ±â°è ¹ø¿ªÀ» ÀÌÇØÇϱ⠾î·Á¿ï ¼öÀÖ½À´Ï´Ù. Please refer to À» ÂüÁ¶ÇϽñ⠹ٶø´Ï´Ù original English article ¿ø·¡ ¿µ¾î ¹®¼ whenever possible. ¾ðÁ¦µç °¡´ÉÇÕ´Ï´Ù.
Share and contribute or get technical support and help at °øÀ¯¿Í ±â¿©Çϰųª ±â¼ú Áö¿ø°ú¿¡ µµ¿òÀÌ My Digital Life Forums ³» µðÁöÅÐ »ýȰ Æ÷·³ .
Related Articles °ü·Ã ±â»ç
- How to Find and Replace Text in MySQL Database using SQL ÅØ½ºÆ® ±³Ã¼ÇÏ´Â ¹æ¹ý°ú SQLÀ» »ç¿ëÇÏ¿© MySQL µ¥ÀÌÅͺ£À̽º¿¡¼ ã±â
- Check and Optimize MySQL Database Automatically with Crontab/Cron MySQL µ¥ÀÌÅͺ£À̽º¿¡ ÀÚµ¿À¸·Î crontabÀ» È®ÀÎÇϰí ÃÖÀûÈ / CronÀº
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL µ¥ÀÌÅͺ£À̽º ¼º´É Æ©´×À» ¸ð¹ü »ç·Ê µ¿¿µ»ó Æ©Å丮¾ó
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database õõÈ÷ ·Î±ë °Ë»ö¾î (õõÈ÷ °Ë»ö¾î ·Î±×)ÀÇ MySQL¿¡¼ µ¥ÀÌÅͺ£À̽º
- How to Remove and Drop Datafiles from Tablespace in Oracle Database ¾î¶»°Ô ³»·Á Datafiles Á¦°ÅÇÏ°í ¿À¶óŬ µ¥ÀÌÅͺ£À̽º Å×ÀÌºí¿¡¼
- Uninstall and Remove Multiple Database Instances of Microsoft SQL Server 2005 Á¦°ÅÇϰí Á¦°ÅÇÏ´Â ¿©·¯ °³ÀÇ µ¥ÀÌÅͺ£À̽º ÀνºÅϽº¸¦ Microsoft SQL Server 2005ÀÇ
- Oracle Database Link Oracle µ¥ÀÌÅͺ£À̽º ¸µÅ©¸¦
- How to Escape Characters in Oracle PL/SQL Queries ¾î¶»°Ô ¿À¶óŬÀº PL / SQL Äõ¸®¿¡ µîÀåÇÏ´Â Àι°À» Å»ÃâÇÏ´Â
- Oracle EXP-00091 Error When Export Database ¿À¶óŬ ÀÖµµ·Ï EXP - 00091 ¿À·ù°¡ ¹ß»ýÇßÀ» ¶§ µ¥ÀÌÅͺ£À̽º ³»º¸³»±â
- Change Oracle Database User Password ¿À¶óŬ µ¥ÀÌÅͺ£À̽º »ç¿ëÀÚ ºñ¹Ð ¹øÈ£ º¯°æ
































