Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

please help on writing a query for updating two table with one query

OpenStudy (anonymous):

i have tried this $query = "UPDATE projects, customersnewlist SET projects.SDPM_ref = '" . $SDPMRef . "',projects.BSCPriorityAdj = '" . $bscprior . "',projects.CMSSAI = '" . $cmssai . "',projects.Clarify_No = '" . $opNum . "',projects.Date_CRD_received = '" . $dateRecieved . "', customersnewlist.CustomerName = '" . $customer . "' WHERE projects.SDPM_ref =" . $SDPMRef;

OpenStudy (anonymous):

I don't think that you can actually update 2 tables with the same query. You can use a join in an update query to update one table based on another, but you can only actually update a single table at a time. One way around this limitation though, is using triggers. If the update to the second table is done using data from the first, and you want it done every time the update is done on the first, you can add a trigger on the table that either updates the second table directly and automatically, or that calls a stored procedure that can use logic to determine whether or not to update.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
2 days ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
2 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!