[thelist] mysql update field based upon another

Anthony Baratta anthony at baratta.com
Fri Jul 25 09:56:27 CDT 2014

On 7/25/2014 7:38 AM, Bob Meetin wrote:
> This seems like it should be fairly simple, but anyhow. I am trying to 
> synchronize the params field of a category, all the items in that 
> category, based upon the params field of an item that is the model. 
> This does not work, is not valid mysql:
> update p3h0i_k2_items set params = (select params from p3h0i_k2_items 
> where id = 300) where id = 278;



     select params from p3h0i_k2_items where id = 300

return more than one record? If so, you can't approach the solution that 

If you want a true sync, you will need to remove all records for 278, 
then insert all selected params for 300 assigning them to 278.

     delete from p3h0i_k2_items where id = 278

     insert into p3h0i_k2_items
     (id, params)
         , params
     from p3h0i_k2_items
     where id = 300

Hope that helps.

Anthony Baratta

More information about the thelist mailing list