and, or statments

mgonzales

Registered User.
Local time
Today, 14:37
Joined
Sep 16, 2009
Messages
44
What is the big difference between the "and" and the "or" statements in when using them as a parameter in an Acces query?

I'm using it to filter out data that I don't need, so I am using "Not Like --- and Not Like" i am also trying "Not like --- or Not Like" They are both pulling data, but my file is like 35k files,so it is hard to determine what is going on. The "and" statements pull 14k and the "or" statements pull 16k.

Thanks
 
The not like or's kinda cancel each other out :)
 
Thank you Higg,
so what your saying is..the "or" statements would still pull some of the info that I dont want? So then the "and not like" statements would be the way to go?
Thanks

The not like or's kinda cancel each other out :)
 
At the most basic Level, an OR Statement will select records that are TRUE for EITHER of the requirements of the OR Statement, while an AND Statement will only select records that are TRUE for BOTH of the requirements of the AND Statement. Take a look at the table below:

Code:
[FONT=Courier New]Values        A=1 OR B=2        A=1 AND B=2[/FONT]
 
[FONT=Courier New]A  B[/FONT]
[FONT=Courier New]1  2           Selected          Selected[/FONT]
[FONT=Courier New]1  1           Selected        Not Selected[/FONT]
[FONT=Courier New]2  2           Selected        Not Selected[/FONT]
 
Last edited:
I am placing the statement in a single field, not across multiple fields. so if i have what is below, what would I get

Values in a single field: 900*, 774*, 556
Statement: not like 900* and not like 774*
Statement: not like 900* or not like 774*


At the Most basic Level, an OR Statement will select records that are TRUE for EITHER of the requirements of the OR Statement, while an AND Statement will only select records that are TRUE for BOTH of the requirements of the AND Statement. Take a look at the table below:

Code:
[FONT=Courier New]Values        A=1 OR B=2        A=1 AND B=2[/FONT]
 
[FONT=Courier New]A  B[/FONT]
[FONT=Courier New]1  2           Selected          Selected[/FONT]
[FONT=Courier New]1  1           Selected        Not Selected[/FONT]
[FONT=Courier New]2  2           Selected        Not Selected[/FONT]
 
Last edited:
I think your best bet is to post some actual sample data like AccessRookie did and explain in plain english what you're trying to do...
 
Or does not make sense on a single field as it can only have one value at a time.

Brian
 
Last edited:
I am placing the statement in a single field, not across multiple fields. so if i have what is below, what would I get

Values in a single field: 900*, 774*, 556
Statement: not like 900* and not like 774*
Statement: not like 900* or not like 774*

While the content may not be what you are looking for, the presentation still seems to have some potential. Perhaps the following will make it a little clearer:
Code:
[FONT=Courier New]Values  [/FONT][FONT=Courier New][FONT=Courier New](Not Like 900) OR (Not Like 774) [/FONT][/FONT][FONT=Courier New](Not Like 900) AND (Not Like 774)[/FONT]
 
[FONT=Courier New][FONT=Courier New] 100[/FONT][FONT=Courier New]              Selected                        [FONT=Courier New] Selected[/FONT][/FONT]
[/FONT][FONT=Courier New][FONT=Courier New] 456[/FONT][FONT=Courier New]              Selected                        [FONT=Courier New] Selected[/FONT][/FONT]
 774              Selected                       Not [FONT=Courier New]Selected[/FONT][/FONT]
[FONT=Courier New][FONT=Courier New] 876[/FONT][FONT=Courier New]              Selected                        [FONT=Courier New] Selected[/FONT][/FONT]
 900              Selected                       Not [FONT=Courier New]Selected[/FONT][/FONT]
 
Values in a single field: 900*, 774*, 556
Statement: not like 900* and not like 774*
Statement: not like 900* or not like 774*

Given the above is the use of Like necessary, ie are you using wild cards to enable searching on parts of field values? If looking at complete values use Not In(,,,,)

Brian
 

Users who are viewing this thread

Back
Top Bottom