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
Do you know what are acid properties?
What types of replication are supported in sql server?
We are updating a field in sql and alter the row also.after giving the commit command the system is crashed.what will happen to the commands given,whether it will update and alter the table or not?
How can you transfer data from a text file to a database table? Or how can you export data from a table to a comma delimited (csv) file? Or how can you import data from ms access to a table in a database? Or how can you export data from a table to an excel file?
When setting replication, is it possible to have a publisher as 64 bit sql server and distributor or subscribers as a 32 bit sql server?
Where is localdb stored?
How to generate create table script on an existing table in ms sql server?
What are different replication agents and what's their purpose? : sql server replication
What is the main difference between ‘between’ and ‘in’ condition operators?
What is data block and how to define data block size?
What are “phantom rows”?
What is the difference between composite index and covering index?
how you can move data or databases between servers and databases in sql server? : Sql server administration
What is microsoft sql server?
what do you understand by change data capture?