SQL Query Help Needed

Posted on 2014-08-13
Last Modified: 2014-08-13
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?
Question by:wantabe2
    LVL 6

    Accepted Solution

    Like this?

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

    Open in new window

    LVL 44

    Expert Comment

    by:Vitor Montalv√£o
    How to know if a task is listed as work or not?
    LVL 20

    Expert Comment

    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...
    LVL 47

    Expert Comment


    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)
    LVL 47

    Expert Comment

    @rjohnsonjr, you must have renewed that mind reading license :)

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now