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 to update values in a table with update statements in ms sql server?
How to bind a view to the schema of the underlying tables?
What are different types of database indexes?
Describe in brief sql server monitoring ways.
What are the restrictions while creating batches in sql server?
What is difference between index seek vs. Index scan?
How to defragment indexes with alter index ... Reorganize?
Find first and last day of current month in sql server
How to get a list all databases on the sql server?
What is BCNF? How is it better than 2NF & 3NF?
Give an example of SQL injection attack ?
What is the process of normalization?
What is an identity?
What are security principals used in sql server 2005?
What is the optimization being performed in oracle and SQL Server?