views:

307

answers:

2

How can you return a string minus the first character in a string in MySQL?

In other words, get 'ello' from 'hello'.

The only way I can think to do it is to use mid() with the second offset being larger than the string could possibly be:

select mid('hello', 2, 99)

But I'm convinced there must be a more elegant way of doing it. Is there?

+7  A: 

Use SUBSTR (or SUBSTRING):

SELECT SUBSTR( 'hello', 2 );
--> 'ello'

See also: MySQL String Functions

Rob
A: 

what about select substr('hello', 2)?

scottm