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'>
SpiderpoisonSpiderpoison
asked Nov 8, 2018 at 11:54
1 Answer 1
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';
*/
answered Nov 8, 2018 at 12:05
-
I had chosen words that confused the question and it was edited in the wrong way causing confusion. I reworded the question! Thank youSpiderpoison– Spiderpoison2018年11月08日 12:08:37 +00:00Commented Nov 8, 2018 at 12:08
-
@user2175345 Your edition makes WHERE clause unnesessary. I'll comment it... Done.Akina– Akina2018年11月08日 12:13:38 +00:00Commented Nov 8, 2018 at 12:13
-
This is not a query with WHERE. Is a replace in a string by a value of a field. See againSpiderpoison– Spiderpoison2018年11月08日 12:17:08 +00:00Commented Nov 8, 2018 at 12:17
lang-sql
COALESCE(field_value, '')
.