View previous topic :: View next topic
|
Author |
Message |
dipumain
New User
Joined: 05 Nov 2006 Posts: 1
|
|
|
|
There are 2 tables A , B ..
There are 3 files C , D and E
now... the conditions to write the records from A & B to C,D,E files .. is...
if the Record found in A and B then write that record into C
if the Record found in A and not in B then write that record into D
if the Record found in B and not in A then write that record into E
.. Plzz place the code for this..
thanking you... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
this kind of thing can be accomplished by sort. there are probably 10 million variations of this question in the SORT forum. plzz look there! |
|
Back to top |
|
|
twissi
Active User
Joined: 01 Aug 2005 Posts: 105 Location: Somerset, NJ
|
|
|
|
Dipu,
The question is unclear, so I'm assuming few things:
Quote: |
if the Record found in A and B then write that record into C |
Code: |
SELECT * FROM Table_A WHERE Pri_Id IN (SELECT Pri_Id FROM Table_B) |
Quote: |
if the Record found in A and not in B then write that record into D |
Code: |
SELECT * FROM Table_A WHERE Pri_Id NOT IN (SELECT Pri_Id FROM Table_B) |
Quote: |
if the Record found in B and not in A then write that record into E |
Code: |
SELECT * FROM Table_B WHERE Pri_Id NOT IN (SELECT Pri_Id FROM Table_A) |
And write the records returned by the queries accordingly.
Cheers, Twissi. |
|
Back to top |
|
|
vijay_bn79
New User
Joined: 20 Nov 2006 Posts: 48 Location: Hyderabad
|
|
|
|
Hi..,
the concept of JOIN i.e
INNER JOIN
OUTER JOIN
Will provide you the solution
Thanks |
|
Back to top |
|
|
|