#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    India
    Posts
    1
    Rep Power
    0

    Cool Help required in building a query


    Hi,

    I am getting problem in building a query.

    I have a table like:

    ID Contact_id code

    1 1001 1
    2 1001 2
    3 1002 2
    4 1002 1
    5 1003 1
    6 1004 1
    7 1004 4
    8 1003 5

    I want to retireve the 'contact_ids' where 'code' equal to 1 and also not equal to 2.

    That means from above table, I should get the following contact_ids:
    1003
    1004 only as they have code equal to one.

    The contact_ids 1001 & 1002 should not be retrieved as they are having a record for code=2 also.


    Can you please help me out?
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,800
    Rep Power
    1104
    I want to retireve [ SELECT ] the 'contact_ids' [ field ] where [ WHERE ] 'code' equal to [ field=1 ] 1 and [ AND ]also not equal to [ field 1= 2 ]2.
    You've written already, you just didn't know it!
    Code:
    SELECT `contact_ids`
    FROM `table`
    WHERE `code`=1
      AND `code`!=2

IMN logo majestic logo threadwatch logo seochat tools logo