none
Cross join question

    Question

  • Create table #TempTable
     (  
     MYteam varchar(30), 
     )

    insert into #TempTable 
     select 'gold'
     union all
     select 'Silver'
     union all
     select 'Platinum'
     union all
     select 'Iron'
     union all
     select 'Plastic'
     union all
     select 'paper'


     select * from #TempTable 

     select * from #TempTable A cross join #TempTable B where A.MYteam <> B.MYteam 

    drop table #TempTable

    These are teams playing with each other, How do i avoid eg. Silver vs gold  cuz there is a gold vs silver.

         
    Friday, April 05, 2013 5:11 PM

Answers

  • I'm not sure exactly what you are looking for, but perhaps

     select * from #TempTable A cross join #TempTable B where A.MYteam < B.MYteam 

    Tom

    • Proposed as answer by Chuck Pedretti Friday, April 05, 2013 5:14 PM
    • Marked as answer by hphil Friday, April 05, 2013 5:16 PM
    Friday, April 05, 2013 5:13 PM