Why would I do an inner join on a non-distinct field?
Posted
by froadie
on Stack Overflow
See other posts from Stack Overflow
or by froadie
Published on 2010-03-22T18:17:33Z
Indexed on
2010/03/22
18:21 UTC
Read the original article
Hit count: 359
I just came across a query that does an inner join
on a non-distinct field. I've never seen this before and I'm a little confused about this usage. Something like:
SELECT distinct all, my, stuff
FROM myTable
INNER JOIN myOtherTable
ON myTable.nonDistinctField = myOtherTable.nonDistinctField
(WHERE some filters here...)
I'm not quite sure what my question is or how to phrase it, or why exactly this confuses me, but I was wondering if anyone could explain why someone would need to do an inner join on a non-distinct field and then select only distinct values...? Is there ever a legitimate use of an inner join on a non-distinct field? What would be the purpose? And if there's is a legitimate reason for such a query, can you give examples of where it would be used?
© Stack Overflow or respective owner