3

Mysql database update question.

I have a table with three fields: TITLE and PARAMS and LEVEL

PARAMS column is a text field: {action="h3",and other information}

TITLE column is a text field: happy

I need to replace/update the h3 in the PARAMS column with the data from the TITLE column

So h3 will be replaced with the data in the TITLE column.

In this example, the h3 is replaced with h4.

UPDATE `m3o7x_menu` SET `params` = REPLACE(`params`, "h3", "h4") WHERE `level`='3';

What is the correct syntax to change h4 to the TITLE column data?

Thanks!

3 Answers 3

1

UPDATE m307x_menu SET params = REPLACE(params,'h3',title) WHERE level = '3';

Sign up to request clarification or add additional context in comments.

Comments

1
UPDATE m3o7x_menu 
SET params = REPLACE(params, '"h3"', concat('"',title,'"') 
WHERE level='3';

1 Comment

Don't know if this is correct, but it is what I would try first.
1

try

UPDATE m3o7x_menu SET params = REPLACE(params, 'h3', 'h4') WHERE level='3';

2 Comments

That is identical to OP's example except you are missing a quote around h4.
I need to change h4 to the data in the TITLE field. The example replaces all instances of h3 with h4. I need to replace all instances of h3 with the data in the TITLE field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.