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
What functions can a view be used to performed?
How do you debug a procedure in sql server?
What is store procedure?
what are the steps you will take to improve performance of a poor performing query? : Sql server database administration
What is the maximum size of a dimension? : sql server analysis services, ssas
What are the differences between char and nchar in ms sql server?
What is an index. What are the types?
What is nonclustered index with included columns ?
What are the different types of sql server replication? : sql server replication
How to see existing views in ms sql server?
What is instead of trigger sql server?
Explain the concepts and capabilities of sql server?
How can I create a new template for import ? : sql server management studio
What are partitioned views?
between cast and convert which function would you prefer and why?