MYSQL REPLACE string content with field value

MySQLreplaceselect

How can I REPLACE a string value with a other field content?

SELECT REPLACE(html_input,'!value',field_value) FROM table

Value of html_input is <input type='text' value='!value'>

Value of field_value is test

Expected result:

<input type='text' value='test'>

Best Answer

String literals must be enclosed by quotes '.

Quote symbols within a literal must be quoted by slash as \'.

SELECT REPLACE(html_input,'!value',field_value) 
FROM table
/* WHERE html_input = '<input type=\'text\' value=\'!value\'>'
     AND field_value = 'test';
*/