Skip navigation links

MySQL Forums


Advanced Search

Cross-Table Update/Select
Posted by: Raymond Chow ()
Date: November 07, 2009 03:36AM

I have two tables, visualized here:
http://img690.imageshack.us/img690/6422/117200942805am.png

I need to update all the (TableA.ToUpdate) fields to 1 where (TableA.owner) matches the (TableB.ID)s where (TableB.CheckThis)>50

I guess I can do it as follows:
Select id from TableB where CheckThis>50
(PHP loop...
Update TableA set ToUpdate=1 where owner=(ID from loop)
...)

But I was wondering if there was a way I could do this with just a single SQL query.

Options: ReplyQuote


Subject Written By Posted
Cross-Table Update/Select Raymond Chow 11/07/2009 03:36AM
Re: Cross-Table Update/Select Peter Brawley 11/07/2009 12:56PM
Re: Cross-Table Update/Select Raymond Chow 11/08/2009 05:22AM


Sorry, only registered users may post in this forum.