Union
With SQL you can combine multiple queries that have the same number of
fields.
Example: We want to combine records from TblProduct table and TblProduct1
table.
TblProduct table:
| ProID | ProName |
UnitPrice |
Qty |
CatID |
| P001 | Angkor |
20$ |
10 |
Cat003 |
| P002 | ABC |
50$ |
8 |
Cat003 |
| P003 | Khmer Noodle |
20$ |
10 |
Cat004 |
TblProduct1 table:
| ProID | ProName |
UnitPrice |
Qty |
CatID |
| P004 | Anchor |
18$ |
13 |
Cat003 |
| P005 | Cocacola |
25$ |
15 |
Cat003 |
SELECT * FROM TblProduct
UNION
SELECT * FROM TblProduct1;
Result:
| ProID | ProName |
UnitPrice |
Qty |
CatID |
| P001 | Angkor |
20$ |
10 |
Cat003 |
| P002 | ABC |
50$ |
8 |
Cat003 |
| P003 | Khmer Noodle |
20$ |
10 |
Cat004 |
| P004 | Anchor |
20$ |
13 |
Cat003 |
| P005 | Cocacola |
25$ |
15 |
Cat003 |
|