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
Why we need sql server?
Why are sql functions used?
What is attribute relationships, why we need it? : sql server analysis services, ssas
List the different types of collation sensitivities in sql server?
Why use stored procedures in sql server?
what are defaults? : Sql server database administration
Explain what is log shipping?
What are triggers? How do you invoke a trigger on demand?
How do you create a data source?
What is cdc in sql server?
What are the joins in sql server? : sql server database administration
What is the difference between ddl,dml and dcl commands?
Define self join?
What are different types of database indexes?
What is store procedure?