Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with the Update command

Status
Not open for further replies.

comadreja

Programmer
Apr 14, 2003
8
ES
Hi, i recently started using mysql and have a problem. How can i run a multi-table update? I mean, update one table regarding the results of a search in another table, like this:
UPDATE software,hardware SET software.name = 'example' WHERE sofwtare.company IN (SELECT hardware.company FROM hadware WHERE hardware.country = 'Spain')

It gives me a syntax error in the select part, and i don´t know why, guess is something stupid but i don´t get it. Can you help me?
If i run this update, in the update.log would appear like that or with the select part already processed?
Thank you very much!
 
Mysql does not support subselect.

Code:
UPDATE software,hardware SET software.name = 'example' WHERE sofwtare.company = hardware.company 
and hardware.country = 'Spain'

May work, requires version 4.0.x though. Take a look at the update statement in the docs, there seems to be some problems with 1 to many relations.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top