Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql cut string, the first character?

Tags:

string

mysql

Hi is it possible to cut string like this:

String in "data" columns: ,123,456

Cut the first character i.e "," (comma).

So the query is something like:

Update users set data = cut first string... 
like image 237
mysqllearner Avatar asked Feb 09 '10 02:02

mysqllearner


People also ask

How do I slice a string in MySQL?

MySQL SUBSTRING() Function The SUBSTRING() function extracts a substring from a string (starting at any position). Note: The SUBSTR() and MID() functions equals to the SUBSTRING() function.

How do I get the first 3 characters of a string in SQL?

SELECT LEN(column_name) FROM table_name; And you can use SUBSTRING or SUBSTR() function go get first three characters of a column.


1 Answers

UPDATE users SET data = SUBSTR(data, 2);

This will iterate through all rows in users and replace data with itself minus the first character.

like image 59
James Cronen Avatar answered Sep 24 '22 17:09

James Cronen