Delete from a table matching a criteria in another table
I have two tables in ACCESS: EMP1 and EMP2. EMP1 has all the inf开发者_运维百科ormation needed, so it has all the columns but EMP2 has only FNAME, LNAME AND MNAME columns in it. In EMP1 there's a column named REGDATE which is the employees registration date. Now I want to delete those employee names from EMP2 whose REGDATE in table EMP1 is smaller than 01-Jan-2010. How do I do that?
Assuming you have IDs (if you don't have IDs, get some quick!) and smaller than 01-Jan-2010 means before 01-Jan-2010:
DELETE FROM EMP2 WHERE ID IN (SELECT ID FROM EMP1 WHERE REGDATE < #01/01/2010#)
精彩评论