MySQL Forums
Forum List  »  General

Re: updating a field using contents of another (json) field
Posted by: Rick James
Date: July 27, 2014 11:19AM

> update p3h0i_k2_items set params = (select params from p3h0i_k2_items where id = 300) where id = 268;

That syntax seems OK unless you are running a version of MySQL older than 4.1. What is the exact error message?

See the online page about multi-table updates.
I got lost on the significance of `params` and JSON, so my UPDATE below may not be doing what you asked.

UPDATE    Items a
    JOIN  Items b SET
        a.title = b.title,
        a.catid = b.catid,
        a.params = b.params,
        ...
    WHERE  a.id = 300
      AND  b.id = 268;

> If I can get the query working I'll set it to update all the records in a category.

WHERE a.catid = ... instead of WHERE a.id = 300?

> There are upwards of 500 items to fix;

By "items", are you referring to rows in the table? Or fields in the table?

Options: ReplyQuote


Subject
Written By
Posted
Re: updating a field using contents of another (json) field
July 27, 2014 11:19AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.