A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Delete Query



 
 
Thread Tools Display Modes
  #1  
Old December 29th, 2009, 01:20 PM posted to microsoft.public.access.queries
Sean
external usenet poster
 
Posts: 491
Default Delete Query

I have 2 tables each have the fields Material and Qty. Table 1 is the master
table and Table 2 is a table of Material and Qty I want to delete from Table
1. I cannot seem to get it to work, can someone help me?
Thanks
  #2  
Old December 29th, 2009, 01:31 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Delete Query

STEP 1: BACKUP your data before attempting the following.
STEP 2: BACKUP your data before attempting the following.

Without a backup you cannot restore the data if this does not work the way you
expect.


This query will delete matching records in Table1.
DELETE
FROM Table1
WHERE EXISTS
(SELECT * FROM TABLE2
WHERE Table2.Material = Table1.Material
And Table1.Qty = Table2.Qty)


On the other hand, if you just want to change the QTY in Table1 based on the
Qty in Table2, you would need to use an update query.



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Sean wrote:
I have 2 tables each have the fields Material and Qty. Table 1 is the master
table and Table 2 is a table of Material and Qty I want to delete from Table
1. I cannot seem to get it to work, can someone help me?
Thanks

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.