开发者

Delete from a table matching a criteria in another table

开发者 https://www.devze.com 2023-03-19 09:29 出处:网络
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 col

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#)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号