Union two rowsets

Hi team!

Is there a simple way to union the results from 2 rowsets? They have the same columns in both results.

Alternatively, is there a way to save all rows in a rowset without iterating through all of them?

thanks!
Michelle

Use the UNION sql keyword and let the database do it for you.

3 Likes

Tim’s recommendation to use the UNION sql keyword is definitely worth a try.

I needed to peform a UNION a few years ago, and was hesitant to try it. I thought that the performance would be bad, but it worked like a charm. Your mileage may vary, as the total number of records involved is not known at this point.

1 Like

I was taught a long time ago to use UNION ALL to avoid performance problems.

This information might be dated, and may not apply equally to all databases. Please feel free to correct me or add details of specific databases you know about.

UNION does not return duplicate records, where UNION ALL will return all records from both queries. The performance issue is UNION eliminating the duplicates. If you either don’t care about potential duplicates, or know you won’t have duplicates then use UNION ALL.

2 Likes