Prev: hi
Next: My Posts
From: SITCFanTN on
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.
From: Dirk Goldgar on
"SITCFanTN" <SITCFanTN(a)discussions.microsoft.com> wrote in message
news:845CAAD2-8B83-4335-9CB4-A29A9E9D6F37(a)microsoft.com...
>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)

From: KenSheridan via AccessMonster.com on
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/Forums.aspx/access/201005/1

From: Jerry Whittle on
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.
From: John W. Vinson on
On Fri, 7 May 2010 12:58:01 -0700, Jerry Whittle
<JerryWhittle(a)discussions.microsoft.com> 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]
 |  Next  |  Last
Pages: 1 2
Prev: hi
Next: My Posts