Intersects and Unions between lists

  • Thread starter Thread starter Animesh Chatterjee
  • Start date Start date
A

Animesh Chatterjee

Hi,

I have 30 lists, each containing 20+ data elements. I need to find the
intersects (elements common to all lists) and unions (all the elements
in all the lists, with duplicates excluded) of all of these lists. I
have been told that a database program is the best way to go about
doing this. However, I have little expeirience with databases, and
would be greatful for any suggestions on how to acheive the above.

Thanks,

Animesh

e-mail: (e-mail address removed)
 
Animesh,

Create a table with a structure
ListID integer
Element text

Call it DataTable

Enter the data so you will have a table looking something like this

ListID Element
1 123
1 234
1 345
2 234
2 345
2 567
3 234
3 345
3 578

and so on.

To get your union create a query using the SQL code

SELECT DISTINCT Element FROM DataTable

To get you intersection use

SELECT Element FROM DataTable GROUP BY Element HAVING COUNT(*)=3

3 is the number of lists you have. You would use 30

I hope you can follow this.

Rod Scoullar
 
Back
Top