Query two tables, combine results and get distinct results

Query two tables, combine results and get distinct results. But I do not want to join the two very large tables. Both tables have multiple entries for the field I am looking to get.

Basically I query first table, spit out DISTINCT field.
then query the second table, spit out DISTINCT field.

Now I want distinct of the two combined results for the field value.

This will give my a unique COUNT of field from either table one or table two, based on the filter applied to each of course.

What specifically do you want? A separate count total for each table -- so that if a value appears in both columns, you get both totals -- or just a list of the DISTINCT values, perhaps with a single count even if in both tables?

The separate DISTINCT list (and count) for each table for field column I already have.

Now need the distinct of the combined of those 2 DISTINCT lists.

But if a given field value is in both tables, what do you want to list?
For example, table1 has "value1" with count of 7, and table2 has "value1" with a count of 3, what "distinct" result do you want to see in your results?

Keep in mind, we know NOTHING about your data. If your data follows certain patterns, tell us about those, because we do not know and cannot know that on our own.

If you just want the distinct values and not a count, then you can do this:


SELECT DISTINCT field
FROM table1
UNION 
SELECT DISTINCT field
FROM table2

Since UNION returns distinct values you don't need DISTINCT in either query.

SELECT field
UNION
SELECT field

Technically, no, but the query could be more efficient if each query specifies DISTINCT.