Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining 2 Recordsets

Status
Not open for further replies.

nigz

Programmer
Jun 15, 2001
60
GB
Hi - I have 2 disconnected recordsets both with same number of fields with same field names and I just want to combine/merge them. What's the best way to do this? BTW there will not be duplications as the key value is unique across both. Thanks

N
 
the way i'd do it is just get 1 recordset with all of the fields in it. You can do this by usin a UNION sql statement when you retrieve the records

for example

SELECT field1, Field2, Field3 FROM TABLE A
UNION ALL
SELECT field1, Field2, Field3 FROM TABLE B

The ALL makes it include duplicates so if you're sure there can be no duplicates the ALL is not needed.
For this to work the fields have to be the same data types and in the same order.



 
the way i'd do it is just get 1 recordset with all of the fields in it. You can do this by usin a UNION sql statement when you retrieve the records

for example

SELECT field1, Field2, Field3 FROM TABLEA
UNION ALL
SELECT field1, Field2, Field3 FROM TABLEB

The ALL makes it include duplicates so if you're sure there can be no duplicates the ALL is not needed.
For this to work the fields have to be the same data types and in the same order.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top