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?
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.
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.
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.
UPDATE Tablename SET Username = Concat('0', Username);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With