Subject Re: SQL design question
Author dianeb77@hotmail.com
--- In ib-support@y..., "Nico Callewaert" <nico.callewaert@p...>
wrote:
> Hi list,
>
> I will make my question clear with an example : I have 2
tables with a me data like this :
>
> Table1 Table2
> ----------------------------------
> LAS LAS
> DRA DRA
> COL COL
> SNY <--- That's the record I
would like to retrieve....
>
> So, to retrieve the common data from the tables is easy with a join,
but what if I like to retrieve all the records from table 2 that don't
exists in table 1. I there a way to do that ?

How many rows are in the two tables? Approximately how many rows in
Table2 don't have a match in Table1?
Are you going to do this query all the time, or is it a one-time
thing? How important is performance? Do usable indexes exist for
these columns?

Anyway ... Something like this should return the rows you want (if I
understood your question):

select * from Table2
where not exists
(select * from Table1
where Table1.Col1 = Table2.Col2)


Of course, there are other queries and procedures that return
equivalent results -- I can't say which is best without knowing your
criteria for deciding what's an acceptable solution.

Hope that helps,
db