select identical and unique rows in different tables

  • Thread starter Thread starter Sander Caerteling
  • Start date Start date
S

Sander Caerteling

I have a database system of three table consisting of partly identical
information.
Now I want a few things:
-I want to select the rows from the tables that are present in all three
tables.
-I want to select the rows from the tables that are present in two tables
and not in the other one.
-I want to select rows that are unique to table 1

Can you help me with the SQL statements that make these selections, because
I don't seem to get it working....
And also, is it possible (in Microsoft Access) to combine these SQL
statements in one big querie?

Many Thanks!
Sander
 
These kind of queries are usually solved by using an INNER JOIN, an Outer
Join, the IN, the Not IN, the EXISTS (...) or the NOT EXISTS (...)
operators. Finally, you can combine all these queries by using the UNION
operator. However, with Access, you cannot use the Query Designed in
graphic mode when you want to use the UNION operator.

This looks like a school assignement?

You don't give us any schema information, so it's hard to give you some
examples; however, here are some:

Select * From Table1 where Table1.Id not In (Select Distinct Id from Table2
Where Table2.Id is not Null)

Select * From Table1 where Not Exists (Select * from Table2 where Table2.Id
= Table1.Id)
 
Back
Top