sql - How can I identify common elements in at least 2 out of 5 tables? -


if have 5 tables, join functions should using if want find elements in single column occur in @ least 2 out of 5 tables?, ie: discarding elements occur in single table.

would code similar if wanted find common elements in @ least 3/5 tables?

(i'm using ms access)

thanks!

i'm not 100% positive understand question, think can use union all this:

select yourcol (   select distinct yourcol t1   union   select distinct yourcol t2   union   select distinct yourcol t3   union   select distinct yourcol t4   union   select distinct yourcol t5 ) t group id having count(*) >= 2 

then can change >= 2 whatever number want.

btw -- if column in question doesn't contain duplicates, can remove distinct subquery.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -