Select all but the first character in the line

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 do this is to use mid (), with the second offset being larger than it can be:

select mid('hello', 2, 99) 

But I am convinced that there must be a more elegant way to do this. There is?

+4
source share
3 answers

Use SUBSTR (or SUBSTRING ):

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

See also: MySQL String Functions

+12
source

This is really wrong. If you do, you will only get llo. To get everything after the first character .... do the following:

 <?php echo substr('hello', 1); // Output ello echo '<br />'; echo substr('hello', 2); // Output llo ?> 

I just wanted to fix it.

Edit: Bah, ignore me. I thought you were talking in PHP. In any case, you can do it in Mysql..or you can just get it in PHP, as I wrote above.

+2
source

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

0
source

All Articles