The join such as INNER JOIN or LEFT JOIN combines columns from two tables while the UNION combines rows from two queries.
In other words, join appends the result sets horizontally while union appends result set vertically.
The following picture illustrates the main difference between UNION and JOIN:
In other words, join appends the result sets horizontally while union appends result set vertically.
The following picture illustrates the main difference between UNION and JOIN:
Conclusion:
Both being data combining operations are used in different situations. JOIN is used when we want to combine attributes of two relations having at least one attribute in common. UNION is used when we want to combine the tuples of the two relations that are present in the query.
No comments:
Post a Comment