26 Feb, 2007
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
Love what you've just read? Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
Other similar 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
- 13 FREE iPhone Apps for Web Developers
- Delete rows older than x days or x months in MySQL
Hello! Welcome to Web development blog! My name is Ei Sabai and on this blog, I write about web development, mobile app development, latest web technologies and the likes. Read more 


What if I want to remove the first character but I don’t know what it will be? Is there a way to say “trim first character, regardless of what character it is”?