I need to update one column if another column has a specific data.
Usually if I want to update one column, I do the following SQL Query:
SET field1 = replace(field1, 'oldstring', 'newstring')
SET page_template = replace(page_template, 'tree_body_spouse_1.html', 'tree_body_single.html')
You could use CASE expression to fulfill different condition of replacement.
UPDATE phpbb_tree SET page_template = (CASE WHEN spouses_total is null THEN replace(page_template, 'tree_body_spouse_1.htm', 'tree_body_single.html') ELSE page_template END );
Please check this..