Jump to content

Updating only records in table with no related record?


Recommended Posts

I have two tables (Companies and Company_machines) and each row in Companies may have several or no related rows in Company_machines. I'm trying to update all the rows in Companies that don't have any related rows in Company_machines. Every row in Company_machines has a Company_ID field that contains the ID of the Company it belongs to in the Companies table. How would I write a MySQL statement that updates just one field in Companies that don't have any Company_machines related to them? Here's what I tried but wasn't successful:

UPDATE Companies coLEFT JOIN Company_machines cm ON cm.company_id = co.idSET co.prospect = "yes"

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...