Delete queries with selection

ozdemirozgur

Registered User.
Local time
Today, 18:35
Joined
Apr 29, 2011
Messages
47
Hi,

I have two tables Table1 and Table 2 which have a common field called "CompanyId". In addition, table 1 has also a field called sector. I would like to deleted the records from Table2, if their corresponding sector in Table1 is Finance. How I can write a simple delete query?

thanks, ozgur
 
The easiest is to build a normal SELECT query in the query builder, that shows only the rows you wish to delete, and then change the query type to a DELETE query
 
thanks, I got the following query but does not work;

DELETE Salaries*
FROM Salaries
WHERE (((Salaries.CompanyId) IN (select CompanyId from Companies) and (Companies.Industry= "Finance")));
 
May I suggest that you do what I outlined in #2?
 
Hi,

I have actually done your suggestion and this is how I got the query above. Can you please let me know which part of the query is wrong?

thanks, ozgur
 
Code:
WHERE Salaries.CompanyID IN (SELECT CompanyId FROM Companies WHERE Companies.Industry= "Finance");
 

Users who are viewing this thread

Back
Top Bottom