Home Forums SQL Server 2005 T-SQL (SS2K5) displaying records only if both the values of a field are avaliable RE: displaying records only if both the values of a field are avaliable

  • ssurekha2000 (8/3/2013)


    i have a table with 5 fields

    field1 will have values as 'd' and 'i'

    if the field1 of table has both the values then only the data shld e displayed

    but if the field1 has only value 'd' then no data shld be displayed

    i have tried select * from #temp1 where col1='d' and col1 ='i'

    but nothing gets displayed

    Usually I would ask for DDL, sample data etc. - as per the link in my signature. But it sounds like you want something like this:

    If exists (select 1 from table where col1 = 'd') and exists (select 1 from table where col1 = 'i')

    begin

    select * from table

    end

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.