Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL query to prepend character to each entry

Tags:

mysql

I have a table of users which has a username column consisting of a six digit number e.g 675381, I need to prepend a zero to each of these usernames e.g. 0675381 would be the final output of the previous example, is there a query that could handle this?

like image 858
Stuart Avatar asked Oct 01 '08 08:10

Stuart


People also ask

How to append a string to a column value in MySQL?

To prepend a string to a column value in MySQL, we can use the function CONCAT. The CONCAT function can be used with UPDATE statement.

How do I add a character to a string in MySQL?

MySQL INSERT() function The original string, the string which will be inserted, a position of insertion within the original string and number of characters to be removed from the original string - all are specified as arguments of the function. Original string. Position of insertion within the original string.

What is append in MySQL?

MySQLMySQLi Database. You can append data to a MySQL database field with the help of in-built CONCAT() function. The syntax is as follows − update yourTableName set yourColumnName = CONCAT(yourColumnName,'AppendValue'); To understand the above concept, let us create a table.


1 Answers

UPDATE Tablename SET Username = Concat('0', Username);
like image 67
daniels Avatar answered Oct 22 '22 01:10

daniels