SQL Query Help Needed

I have the following query that pulls the data from a mysql database.

$query="SELECT sid, name, status, task FROM supervision WHERE name = 'employee1' AND active='1'";

Open in new window


The above code works great. I'm trying to add to it but can't figure out how to make it pull all task except any that is listed as work.

How would I edit the query to display all the task except any listed as WORK?
LVL 15
wantabe2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rjohnsonjrCommented:
Like this?

$query="SELECT sid, name, status, task FROM supervision WHERE name = 'employee1' AND active='1' and task!='work'";

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
How to know if a task is listed as work or not?
0
n2fcCommented:
You neglect to say if WORK is a value of one of your selected fields or another field...

Assuming WORK is a value of "status" you would add:
AND status <> 'WORK' to your select...

If it is associated with another field, adjust the AND clause as appropriate...
0
PortletPaulfreelancerCommented:
@wantabe2

My mind reading license expired, or was it my because crystal ball rolled off the desk....

It really isn't fair to make us volunteers guess how a table only you have access to defines if a task is 'work' or not 'work', the relevant facts should be included in the question - and we will fall over ourselves to provide the correct sql syntax

We really only know a table exists called `supervision` with these fields:
`sid`, `name`, `status`, `task` , `active`

`name` and `active` both appear to hold strings (not sure why `active` would do that)
0
PortletPaulfreelancerCommented:
@rjohnsonjr, you must have renewed that mind reading license :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.