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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Simple Delete Query



 
 
Thread Tools Display Modes
  #1  
Old May 7th, 2010, 08:36 PM posted to microsoft.public.access
SITCFanTN
external usenet poster
 
Posts: 49
Default Simple Delete Query

I have a table that includes the field titled "State". I want to delete all
records in a table except records that have "AZ", "CT" or "NY" in the state
field. I have tried the criteria of =Not "AZ" or"CT or "NY", but I'm not
getting the correct results. I only retain AZ records. Any help you can
provide is appreciated, thank you.
  #2  
Old May 7th, 2010, 08:44 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Simple Delete Query

"SITCFanTN" wrote in message
...
I have a table that includes the field titled "State". I want to delete
all
records in a table except records that have "AZ", "CT" or "NY" in the
state
field. I have tried the criteria of =Not "AZ" or"CT or "NY", but I'm not
getting the correct results. I only retain AZ records. Any help you can
provide is appreciated, thank you.



Try this:

DELETE FROM [YourTableName]
WHERE [State] Not In('AZ', 'CT', 'NY')


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old May 7th, 2010, 08:52 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Simple Delete Query

Try:

DELETE *
FROM [YourTable]
WHERE State NOT IN("AZ","CT","NY");

Ken Sheridan
Stafford, England

SITCFanTN wrote:
I have a table that includes the field titled "State". I want to delete all
records in a table except records that have "AZ", "CT" or "NY" in the state
field. I have tried the criteria of =Not "AZ" or"CT or "NY", but I'm not
getting the correct results. I only retain AZ records. Any help you can
provide is appreciated, thank you.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201005/1

  #4  
Old May 7th, 2010, 08:58 PM posted to microsoft.public.access
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Simple Delete Query

Not "AZ" or Not "CT" or Not "NY"

This is cleaner:

Not In ("AZ", "CT", "NY")

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"SITCFanTN" wrote:

I have a table that includes the field titled "State". I want to delete all
records in a table except records that have "AZ", "CT" or "NY" in the state
field. I have tried the criteria of =Not "AZ" or"CT or "NY", but I'm not
getting the correct results. I only retain AZ records. Any help you can
provide is appreciated, thank you.

  #5  
Old May 7th, 2010, 09:12 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Simple Delete Query

On Fri, 7 May 2010 12:58:01 -0700, Jerry Whittle
wrote:

Not "AZ" or Not "CT" or Not "NY"


Sleepy, Jerry? g

That should be "AND" rather than "OR" - "AZ" is in fact Not "NY", so this
criterion will delete all records in the table!

This is cleaner:

Not In ("AZ", "CT", "NY")


Absolutely better.
--

John W. Vinson [MVP]
  #6  
Old May 10th, 2010, 06:31 PM posted to microsoft.public.access
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Simple Delete Query

Looks like I need a brain reboot. One dope-slap self-applied to the head.

Thanks John!
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"John W. Vinson" wrote:

On Fri, 7 May 2010 12:58:01 -0700, Jerry Whittle
wrote:

Not "AZ" or Not "CT" or Not "NY"


Sleepy, Jerry? g

That should be "AND" rather than "OR" - "AZ" is in fact Not "NY", so this
criterion will delete all records in the table!

This is cleaner:

Not In ("AZ", "CT", "NY")


Absolutely better.
--

John W. Vinson [MVP]
.

 




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 10:47 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.