What is the difference between join and union.
Answers were Sorted based on User's Feedback
Answer / preeti mishra
Join:- Joins are used to query data from two or more
tables, based on a relationship between certain columns in
these tables.
Union:- UNION operator combines two or more SELECT
statements.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / mohan
join is used to combine two different tables where as in union
union also perform the same operation but the difference is
union will return distinct(unique) values.we can eliminate
the duplicate records while using union
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / prasad
The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.
The UNION operator is used to combine the result-set of two or more SELECT statements.
Notice that each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / viswanath
Both of them are two different operations, but both are
used for merging. However, UNION used for Vertical merge
where as JOIN used for Horizontal merge.
We can never use these two distinct operations
interchengably.
| Is This Answer Correct ? | 1 Yes | 0 No |
for SET operators the resultant column set should be same for the tables.
i.e.
select * from boy
union
select * from girl
will give an error if they have different column
but in join you can corellete the column to each other.
select * from boy,girl where boy.id_gender=girl.id_gender;
will give result
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / rupesh singh
Join is used to MERGE the data from 2 or more different
tables, while union is used to APPEND the data based on
different conditions.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / krish
Blue Shark
he is right but the union O/P
is wrong
1 hammer 3 $ 1
2 screwdriver 5 $ 2
this is right
it won't select duplicates
union all will do.
thanks
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / rajan nadal
In join method join the two table by Atleast one row
match enough to join that tables
but in union
union can be combine the two select satement in the table
here the two select stament table having same number of
column and and datatype then only combine the two select
statement.here union display distinct values but union all
display all the values
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / nafisul haque
Join returns matching/non matching records as per condition
where as union returns union of recordsets. Join is used
within single select statement while union is used among
two or more select statements.
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / susanta
In join retrive column and in union retrive rows.
| Is This Answer Correct ? | 0 Yes | 2 No |
What is the usage of when clause in trigger?
Is sqlite free?
How would you pass hints to the sql processor?
What does (*) mean in sql?
How can u find column name from a table which have max value in a row.( not max value)
What are its different types of dbms?
how to return query output in html format? : Sql dba
How do I remove all records from a table?
what is the difference between truncate and delete statement? : Transact sql
How do you create a unique index?
What is Histogram?
How to use sql*plus built-in timers?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)