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


Please Help Members By Posting Answers For Below Questions

Explain transaction server explicit transaction?

501


What is the difference between executequery () and executeupdate ()?

512


whats the maximum size of view state??

1718


What do you understand by hotfixes and patches in sql server?

515


How can we improve performance by using SQL Server profiler?

571






What are commonly used mssql functions in php?

556


What is an sql server agent?

542


Please explain what is “asynchronous” communication in sql server service broker?

506


What is log cache in sql server?

515


mention different types of relationships in the dbms?

501


How to configure and test odbc dsn settings?

569


What are the steps to process a single select statement?

509


List the data types available in mssql?

524


What do you need to connect php to sql server?

535


List out different types of normalizations in sql server and explain each of them?

551