[thelist] MySQL Query problem: unique vals from two fields

Matt Warden mwarden at gmail.com
Wed Nov 22 13:02:47 CST 2006

On 11/22/06, Pringle, Ron <RPringle at aurora-il.org> wrote:
> To close this out, turns out you don't need to use DISTINCT in the
> query. The default behavior of UNION in MySQL is to remove duplicate
> rows anyhow. So the final query now looks like:

To clarify, you are saying that for a unioned set A and B, where A
and/or B have duplicates within its own set, the union operation will
remove such duplicates? So, it must combine sets and then perform the
un-dupe over the entire set, rather than take set A and only append
from set B if the item in set B is not found in A.

Did you do any tests to make sure the DB does not use a different
algorithm when it knows the two sets have no dupes already?

Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list