Combining recordsets
Sometimes, you will find that you have obtained recordsets that are not exactly what you need. This recipe shows various ways of combining them.
Getting ready
To use this recipe, you need to have two or more recordsets for the same model.
How to do it...
Perform the following steps to perform common operations on recordsets:
- To merge two recordsets into one while preserving their order, use the following operation:
result = recordset1 + recordset2
- To merge two recordsets into one while ensuring that there are no duplicates in the result, use the following operation:
result = recordset1 | recordset2
- To find the records that are common to two recordsets, use the following operation:
result = recordset1 & recordset2
How it works...
The class for recordsets implements various Python operator redefinitions, which are used here. Here's a summary table of the most useful Python operators that can be used on recordsets:
...