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
How can I check that whether automatic statistic update is enabled or not?
What is the order by used for?
How you would rewrite the sql query to return the customerid sorted numerically?
What is clustered vs nonclustered index?
Explain the properties of a relational table?
Data table as parameter in sql server?
When would you use an insert into .. Select option versus an insert into .. Values option? Give an example of each?
How you trouble shoot when any job fails
What happens if date-only values are provided as date and time literals?
What do you understand by physical_only option in dbcc checkdb?
What are the types of joins in sql?
How do you rebuild an identity column?
Explain how does the report manager work in ssrs?
What are the Advantages of using CTE in sql server?
What is the current limitation of the size of SQL Azure DB?