how to replace part of a string with another string in MySQL

How to replace part of a string with another string in MySQL?

 

i would like to replace space from T character in mysql.

Add Comment
1 Answer(s)

Example Query:

SELECT name,
  REPLACE( part_number, '-', '/' ) as new_part_number
FROM motorbike_sale;

Use the MySQL REPLACE() function to replace a substring (i.e. words, a character, etc.) with another substring and return the changed string. This function takes three arguments:

  • The string to change. (In our example, it’s the column part_number.)
  • The substring to replace (i.e. the character ‘-’).
  • The substring to insert (i.e. the character ‘/’).

Notice that this function replaces all occurrences of the substring in the given string or column. In our example, each part_number contains three hyphen characters, each one of which was replaced by a slash.

Answered on May 23, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.