Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Performance - INNER JOINT to the same table

$
0
0

HI!

Which of the next structures is most efficient?

1-
SELECT DISTINCT a.ID
FROM table a    
 inner join table b  
  on a.column1 = b.column1
  and a.column2 = b.column2 
  and a.ID <> b.ID

or

2-
SELECT DISTINCT a.ID
FROM table a    
 inner join table b  
  on a.column1 = b.column1
  and a.column2 = b.column2 
where a.ID <> b.ID

1 or 2 ?

It's to remove the repeated data in my database

Thanks.



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>