Welcome to Dream.In.Code
Become an Expert!

Join 150,149 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,360 people online right now. Registration is fast and FREE... Join Now!




using SELECT as filter

 
Reply to this topicStart new topic

using SELECT as filter, A query thats selects all records except those i don't want

qqwetiqewq
5 Aug, 2008 - 06:57 AM
Post #1

New D.I.C Head
*

Joined: 26 Sep, 2007
Posts: 14


My Contributions
I want an SQL statement in MS Access that will get all records except for those I don't want.

At the moment I have one table "Threes" and one attribute "AThree"
The table is filled with the numbers from 000 to 999.

I want a list of all numbers that don't start with say 3 or 5, and don't end in 4, 1 or 9.

What I would try is:

CODE
SELECT * FROM Threes
WHERE AThree <> "3##"
AND AThree <> "5##"
AND AThree <> "##4"
AND AThree <> "##1"
AND AThree <> "##9"


Am i confident that:
i) the code's wrong
ii) there's an easier way

Please help. smile.gif

User is offlineProfile CardPM
+Quote Post

MrWobbles
RE: Using SELECT As Filter
5 Aug, 2008 - 08:28 AM
Post #2

D.I.C Head
**

Joined: 11 Apr, 2008
Posts: 84



Thanked: 2 times
My Contributions
CODE
SELECT * FROM Threes
WHERE AThree <> LIKE '3%'
AND AThree <> LIKE '5%'
AND AThree <> LIKE '%4'
AND AThree <> LIKE '%1'
AND AThree <> LIKE '%9'


The % is the wild card, and one will include anything before or after or both, depending on where it is placed.

Also this is a good place to go for any further questions:

http://www.w3schools.com/sql/default.asp

This post has been edited by MrWobbles: 5 Aug, 2008 - 08:30 AM
User is offlineProfile CardPM
+Quote Post

qqwetiqewq
RE: Using SELECT As Filter
5 Aug, 2008 - 08:52 AM
Post #3

New D.I.C Head
*

Joined: 26 Sep, 2007
Posts: 14


My Contributions
Thanks, that really helped smile.gif
User is offlineProfile CardPM
+Quote Post

kikz
RE: Using SELECT As Filter
5 Aug, 2008 - 02:44 PM
Post #4

New D.I.C Head
*

Joined: 21 Jul, 2008
Posts: 32



Thanked: 1 times
My Contributions
Can you improve that further with

CODE

WHERE AThree NOT LIKE '[35]%' And AThree NOT LIKE '%[419]'

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:30AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month