This topic is locked

Where clause help needed

4/22/2008 9:43:56 PM
PHPRunner General questions
O
OLDmrcaseyman author

I have a mysql query that is not working and I can't figure out why:
Select Where (Fueled !=1 AND Cleaned !=1) AND isitshipped !=1
I want to see records for vehicles that are either fueled or cleaned, but not both fueled and cleaned AND that are not shipped.

A
alang 4/23/2008

Couple of things to consider:

  1. I would normally expect "SELECT * FROM <tablename> WHERE ..." as the basic SQL statement
  2. Not sure your logic is what you want. The brackets don't do anything as you are effectively ANDing three terms (not fueled, not cleaned, not shipped). Check out http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/ for further assistance in this regard.

T
thesofa 4/24/2008

I have a mysql query that is not working and I can't figure out why:

Select Where (Fueled !=1 AND Cleaned !=1) AND isitshipped !=1
I want to see records for vehicles that are either fueled or cleaned, but not both fueled and cleaned AND that are not shipped.



I think it should be

Select * from <tablename>Where (Fueled !=1 OR Cleaned !=1) AND isitshipped !=1

try that please

O
OLDmrcaseyman author 4/24/2008

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=28484&image=1&table=forumreplies' class='bbc_emoticon' alt=':wacko:' /> >

I think it should be

Select * from <tablename>Where (Fueled !=1 OR Cleaned !=1) AND isitshipped !=1

try that please


Thank you, that works great. I had a little brain malfunction there.