Subject | Re: SQL design question |
---|---|
Author | dianeb77@hotmail.com |
Post date | 2001-06-01T20:19:11Z |
--- In ib-support@y..., "Nico Callewaert" <nico.callewaert@p...>
wrote:
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
wrote:
> Hi list,tables with a me data like this :
>
> I will make my question clear with an example : I have 2
>would like to retrieve....
> Table1 Table2
> ----------------------------------
> LAS LAS
> DRA DRA
> COL COL
> SNY <--- That's the record I
>but what if I like to retrieve all the records from table 2 that don't
> So, to retrieve the common data from the tables is easy with a join,
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