SQL Query question

  • I know that I can run query using "IN" statement example

    select name, street from employee where name in ('name1',name2',......)

    the result is it will show all records for which name can be found from the "IN" statement.

    Is there some way I could have query that will show all names even the ones that are not in the table. I know this can be done

    using LEFT JOIN, if the name you search exist in some other table, but thats something I would like to avoid if possible

    if it's something that can be done using temp table that would work also, need to some advice/example on doing this.

  • Can you be a bit more specific? All the names from where? Not in what table?

    Table definition, sample data and expected results would help.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • What do you expect to see in the result set ?

    Do you want to display records that are contained in the "IN" clause - and then display records that are NOT in the "IN" clause with an "Indicator" saying "IN" or "OUT" ?

    Please provide some sample data and expected result set.

    Thanks

    ________________________________________________________________________________________________
    Regards
    Steve
    SQL 2008 DBA/DBD - MCTS/MCITP

    Please don't trust me, test the solutions I give you before using them.

  • This is what you want?

    SELECT * FROM AnyTable WHERE AnyColumn NOT IN (Value1, Value2, ..., ValueN)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply