MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Philippe Poelvoorde Date:September 19 2006 2:29pm
Subject:Re: query question: updating between 2 tables
View as plain text  
2006/9/19, Peter Van Dijck <petervandijck@stripped>:
> Hi all,
> trying to figure out if there is a query I can use for this, or if I
> have to write a php script to loop tru each row...
>
> table1:
> entryid int(11)
> itemid int(11)
>
> table2:
> object_id int(11)
> ....
>
> The situation is: table2.objectid is populated with the values of
> table1.itemid, but they have to be replaced with the corresponding
> table1.entryid.
>
> I could do in PHP:
> - select * from table2
> - for each row, update table2 with select from table1
>
> but I am wondering if there is 1 query that could take care of this?
>
> Peter

something like :
update table2,table1 set table2.objectid=table1.itemid where
table1.entryid=table2.objectid

you need 4.0 at least IIRC.

-- 
http://www.myspace.com/sakuradrop : credit runs faster
http://www.w-fenec.org/  Rock Webzine
Thread
query question: updating between 2 tablesPeter Van Dijck19 Sep
  • Re: query question: updating between 2 tablesPhilippe Poelvoorde19 Sep