Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,547 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,178 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! 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
post 5 Aug, 2008 - 07: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

Go to the top of the page


MrWobbles
post 5 Aug, 2008 - 09:28 AM
Post #2


D.I.C Head

**
Joined: 11 Apr, 2008
Posts: 54


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 - 09:30 AM
User is offlineProfile CardPM

Go to the top of the page

qqwetiqewq
post 5 Aug, 2008 - 09: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

Go to the top of the page

kikz
post 5 Aug, 2008 - 03: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

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 10:14PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month