|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help with queryHi, I would like some help with a query. I would like to delete all
rows when the key appears in one table and not the other. For example the info in table 1 on my DB is my current work. I then import the upto date info monthly into table 2. Currently I have to manually delete the info from table 2, hence the need for the query to mismatch and leave me with the current info. Hope this makes sense Thanks )It's ususally a good idea to start a new thread so that your request for help doesn't get lost in someone else's responses. Also good to provide table DDL and sample data in the form of INSERT statements.)
One way to do this is: DELETE Table2 WHERE Table2.Key IN ( SELECT Table1.Key FROM Table1 WHERE {criteria in Table1} ) Or vice versa to delete from Table1 Let me know if this helps. -- Show quoteArnie Rowland, YACE* "To be successful, your heart must accompany your knowledge." *Yet Another Certification Exam "John" <john_sarah_k***@hotmail.co.uk> wrote in message news:1151180034.679815.100870@b68g2000cwa.googlegroups.com... > Hi, I would like some help with a query. I would like to delete all > rows when the key appears in one table and not the other. For example > the info in table 1 on my DB is my current work. I then import the upto > date info monthly into table 2. Currently I have to manually delete the > info from table 2, hence the need for the query to mismatch and leave > me with the current info. > > Hope this makes sense > > Thanks > |
|||||||||||||||||||||||