I need help with a select where or statement

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

I cannot get this sql to meet both criteria. How do I
write an or statement:

The crieria:
Status does not equal "Complete"
Type does not contain any part of "District"

Can anyone help?

Thanks

mysql="Select Course, Start_date, Location, ClassID, Type
FROM Classes " &_
"Where (Status <> 'Complete') or (Type Not Like '%
District%') Order by Course Desc"
 
mysql="Select Course, Start_date, Location, ClassID, Type
FROM Classes " &_
"Where (Status <> 'Complete') or (Type Not Like '%
District%') Order by Course Desc"

And whats the problem with that ? Does it not give the result you expect ?
In this case, pls provide an extract of your table, the result you expect
and the result that the query axctually returns... so we can figure out what
goes wrong here.
 
Actually it does meet either unless I remove the first or second part of the
"Or" statement.
 
AnnieS said:
It meets the first criteria but no the second.

Is the or statement correct?

When you put an OR condition it is sufficient for a record to satisfy the
first. The condition "A or B" is satisfied for a record R when it satisfies
just A, just B or both A and B. If you want only those records that satisfy
both A and B you must use an AND condition: "A and B".
 
Thanks for helping!

I do not want a return if the Record Field Type has any part of the word
"District" nor I do not want a return if the Record Field Status equals the
word "Complete"

This would be an OR statement correct?

Dave
 
I do not want a return if the Record Field Type has any part of the word
"District" nor I do not want a return if the Record Field Status equals the
word "Complete"

This would be an OR statement correct?

Lets see...

A := "the Record Field Type contains "District""
B := "Record Field Status equals the word "Complete""

You say: "I do not want a return if A nor do I want a return if B".

<--->

that is equivalent to: "I do not want a return if A or if B"

<--->

that is equivalent to "I do not want a return if (A or B)"

<--->

that is equivalent to "I want rows that satisfy NOT(A or B)"

<--->

that is equivalent to "I want rows that satisfy ( (NOT A) AND (NOT B) )"

<--->

that means "SELECT ... WHERE (NOT A) AND (NOT B)"

<--->

that means "SELECT ... WHERE (NOT "the Record Field Type contains
"District"") AND (NOT "Record Field Status equals the word "Complete"")"

<--->

that means "SELECT ... WHERE (Type Not Like '%District%') AND (Status <>
'Complete')"

Good luck
:)
 
Thank you!!!!!!

Dave

André Hartmann said:
Lets see...

A := "the Record Field Type contains "District""
B := "Record Field Status equals the word "Complete""

You say: "I do not want a return if A nor do I want a return if B".

<--->

that is equivalent to: "I do not want a return if A or if B"

<--->

that is equivalent to "I do not want a return if (A or B)"

<--->

that is equivalent to "I want rows that satisfy NOT(A or B)"

<--->

that is equivalent to "I want rows that satisfy ( (NOT A) AND (NOT B) )"

<--->

that means "SELECT ... WHERE (NOT A) AND (NOT B)"

<--->

that means "SELECT ... WHERE (NOT "the Record Field Type contains
"District"") AND (NOT "Record Field Status equals the word "Complete"")"

<--->

that means "SELECT ... WHERE (Type Not Like '%District%') AND (Status <>
'Complete')"

Good luck
:)
 
Back
Top