Subject Re: [firebird-support] Re: select from 2 tables with certain values identical
Author Thomas Besand
Hi set,

>Is that enough to get you going?
>
Definitely! And thanks a lot for your efforts.
I was just puzzled by this construction of yours:
<snip>

>select cast(2 as SmallInt), a.fld1, ''
>from a
>where not exists(select * from b
>where A.fld2=B.fld6 and A.fld3=B.fld7 and A.fld4=B.fld9)
>union
>select cast(3 as SmallInt), '', b.fld1
>from b
>where not exists(select * from a
>
<snap>
And *that* still does not make much sense to me; but as you kindly split
things up for me, I am going to use those *really simple* client side
queries.
Thanks again,
cu
Thomas Besand
Berlin, Germany (also quite chilly, and wet from time to time, which
means 10 min. in every hour)


Svein Erling Tysvær schrieb:

>Ok, Thomas, here goes:
>
>1. Give me all records from A and B
>where A.fld2=B.fld6 and A.fld3=B.fld7 and A.fld4=B.fld9;
>
>select <something>
>from a
>join b on A.fld2=B.fld6 and A.fld3=B.fld7 and A.fld4=B.fld9
>
>2. Give me all records from A and B excluding those that were
>returned by the above query;
>
>I'd prefer to split this into two separate questions:
>
>2a. All records from A that doesn't have a matching record in B
>
>select <something>
>from a
>where not exists(select * from b
>where A.fld2=B.fld6 and A.fld3=B.fld7 and A.fld4=B.fld9)
>
>2b. All records from B that doesn't have a matching record in A
>
>select <something>
>from b
>where not exists(select * from a
>where A.fld2=B.fld6 and A.fld3=B.fld7 and A.fld4=B.fld9)
>
>You may concatenate the two above queries using UNION, but be aware
>that the types then must match.
>
>
>Set
>(chilly) Oslo, Norway
>
>--- In firebird-support@yahoogroups.com, Thomas Besand wrote:
>
>
>>Hi set,
>>thanks for your answer, *but* ;-)
>>you call that a 'simple query' on the client side, eeh?
>>
>>I tried to fiddle around with it; but I don't get the meaning. Can
>>you put me on the track?
>>
>>BTW: I don't need the records in one resultset.
>>for one query I need :
>>
>>1. Give me all records from A and B where A.fld2=B.fld6 and
>>A.fld3=B.fld7 and A.fld4=B.fld9;
>>
>>and for another one, depending on the user's choice:
>>2. Give me all records from A and B excluding those that were
>>returned by the above query;
>>
>>
>