What is the difference between the SQL keywords union
and join
?
views:
174answers:
4
+13
A:
The UNION
operator is used to combine the result-set of two or more SELECT
statements.
The JOIN
keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.
The tutorials on these two topics (linked to above) on w3schools.com go into further detail.
Dominic Rodger
2010-05-17 08:46:57
Also, A union is from the branch of mathematics called set theory. This is a good image of a unionhttp://en.wikipedia.org/wiki/File:Venn0111.svg
Winter
2010-05-17 22:03:14
+1 for including links
Andrew Heath
2010-05-18 06:29:01
A:
Union is a combination of elements from multiple sets.
Join is a subset of the cross product of multiple sets
Midhat
2010-05-17 08:49:49
A:
If need combinate more then one queries use operator Union, this operator execute first query and the second query, and then return all result in one dataset see more
select field from t1
union
select field from t2
If need create query to select data from two or more table then use operator join see more
select t1.field, t2.field
from t1.number inner join t2.key on t1.number=t2.key
Andriy Mytroshyn
2010-05-17 10:16:53