What are the differences between UNION and JOINS?
Answers were Sorted based on User's Feedback
Answer / saravakumar
A join selects columns from 2 or more tables. A union
selects rows.
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / sree
UNION:The SQL UNION operator combines two or more SELECT
statements.
JOINS:SQL joins are used to query data from two or more
tables, based on a relationship between certain columns in
these tables.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / 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 |
WHY CAN WE CREATE ONLY ONE CLUSTERED INDEX ON A TABLE IN SQL SERVER?
Issues related in upgrading SQL Server 2000 to 2005 / 2008
how to take backup bcp out for a column in table in sql server?
Explain database normalization?
Define the term DML, DDL and DTL?
What are the differences between char and nchar in ms sql server?
How do I find the sql server version?
What are the purposes and advantages stored procedure?
What are synonyms?
Can we use where clause with group by?
Relational calculus is what type of language?
What are security principals used in sql server 2005?