What is the differences between UNION & JOINS in sql server?
Purushottam Rathore
A 'Union selects rows' and Join 'selects columns from 2 or more tables'.
JOIN: A Join is used for displaying columns with the same or different names from different tables. The output displayed will have all the columns shown individually. i.e. The columns will be aligned next to each other. UNION: The UNION set operator is used for combining data from two tables which have columns with the same datatype. When a UNION is performed the data from both tables will be collected in a single column having the same datatype.
A join selects columns from 2 or more tables. A union selects rows
joins is used in our query like,SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_nameand union is used to merge the result of two querylike,select * from table1unionselect * from table2