UNION and UNION ALL
UNION
- use to select related information from two or more table
- selected column should use same data type
- selected column count should be equal
- Return DISTINCT value ( remove duplicate records)
UNION ALL
- Same as UNION , except that it pull all rows in selected table (which mean it doesn't consider duplicate records).
If you know that all records are unique , it's better to use UNION , otherwise use UNION ALL
No comments:
Post a Comment