26 Feb, 2007
Remove the first character in mysql
Web Development » Snippets » Remove the first character in mysql
UPDATE `tablename` SET `columnname` = TRIM(LEADING 'THE CHARACTER YOU WANT TO REMOVE, eg: A' FROM `columnname`);
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)
Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.
mysql> SELECT TRIM(' bar ');
-> 'bar'
mysql> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx');
-> 'barxxx'
mysql> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');
-> 'bar'
mysql> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
-> 'barx'
This function is multi-byte safe.
Source: MySQL 5.0 Reference Manual
Other similiar posts that you might be interested in:
- Sun acquired MySQL for $1 billion
- Dropdown menu population using JSON and jQuery
- 15 tips on optimising MySQL databases and MySQL queries
- Why are my subqueries slow?
- Links Love Series 2: MySQL server fine tuning and administrating
- Delete rows older than x days or x months in MySQL
- 15 useful cheat sheets for web developers






