sort of OT: MySQL question

Jason Hayes jason at jasonhayes.org
Wed Nov 19 11:21:18 MST 2008


Does anyone know the syntax for updating a MySQL database when you are trying 
to pull the information from another temporary holding table in the same 
database?

My updates are normally accomplished like this,

$query = "UPDATE maindbase SET category1='$cat1', category2='$cat2' WHERE 
somevariable=$z";

I know that to pull the data from the temporary database and insert it as a 
new field in the main database, I would do this,

$query = "INSERT INTO maindbase (category1, category2) SELECT category1, 
category2 FROM tempdbase WHERE somevariable=$x";

I don't want to add a new entry in the database, however. I want to update an 
existing entry. How would I go about blending those two queries to mix pulling 
information from the temporary database and updating a field in the main 
database?

Any thoughts? Thanks!

-- 
Jason Hayes



More information about the PLUG-discuss mailing list