SQL Server Performance

How to use "IN" keyword

Discussion in 'General Developer Questions' started by fatimaxaidi, Mar 10, 2008.

  1. fatimaxaidi New Member

    Can neone help me in following scenario:
    I have a table with these specifications: table1(part_number, part_status, part_condition)
    part_status can be either 1 or 2 where 1=Available part and 2=Unavailable part.
    part_condition ranges between 1 to 3.
    can anyone tell me how to write a query that gimme "available" parts in all "3" conditions.
    I used this one but didn't get the valid result:
    select Part_Number from table1
    where part_status = 1 AND part_condition IN (1,2,3)
  2. Adriaan New Member

    The only filtering is on part_status = 1. Because the value on the part_condition column is irrelevant to the filtering, you simply should not mention that column in the WHERE clause.
    My best guess why you're not seeing certain rows is that the part_condition column is perhaps nullable, and the missing rows have a null on the part_condition column.
  3. FrankKalis Moderator

    [quote user="Adriaan"]
    My best guess why you're not seeing certain rows is that the part_condition column is perhaps nullable, and the missing rows have a null on the part_condition column.
    [/quote]
    My guess would be, that this is a homework...
  4. ScottPletcher New Member

    [listening.]
  5. Luis Martin Moderator

    I've moved to relevant forum.
    BTW: Still on vacation.[:)]

Share This Page