What are the differences between UNION and JOINS?
Answer Posted / nikhila reddy
UNION:the both tables should have same structure and datatype.
the column name will taken as first table ones it wont bother abt other tables.
example:
emp table as
eid ename esal
1 a 10k
2 b 20k
dept table as
deptid deptname deptsal
11 aa 20k
12 bb 50k
select * from emp
union
select * from dept
empid empname empsal
1 a 10k
2 b 20k
11 aa 20k
12 bb 50k
now u can observe col name taking alias of first table.
no need of relation between a tables.
it will remove duplicate records.
joins:it will join only required fields from different tables.
no need of same structure for tables..
it should have relation between a tables.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Do you know how to send email from database?
explain different types of joins? : Sql server database administration
How to scale out a federation by Sql statement?
Explain the purpose of indexes?
What programming language would you use to create embedded functions in ssrs?
what data regions are and what are the different data regions?
What are the pros and cons of putting a scalar function in a queries select list or in the where clause?
What is the bookmark lookup and rid lookup?
How do you rebuild an identity column?
How many replicas are maintained for each SQL Azure database?
Explain the xml support sql server extends?
What is the difference between lock, block and deadlock? : sql server database administration
How do I view a script in sql server?
What is the current limitation of the size of SQL Azure DB?
Explain subquery and state its properties?