What is the difference between join and union.

Answer Posted / uchit shah

A Union and Join are similar in that they both are combining
two tables to form another table. However they do this
combining in different ways. The geometry is different.

Lets say for Table A and Table B
Union : -
|A|
-
|B|
-

Join : - -
| A | B |
- -

Union :
(1) In Union Two Rows of one table must fit onto the other
table. The Number of columns in the result table is the same
as the number in both tables. No new Columns are added.

(2) Maximum Number of rows = Sum of Number of rows in the
two tables.

Join :
(1) In Join the rows of one table may be different from the
rows of another table. The result table can contain columns
from both the first and second tables. It can contain all
the columns of first table and all the columns of second tables.

(2) Maximum Number of rows = Product of rows in two tables.

Is This Answer Correct ?    25 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to fetch common records from two tables? : Sql dba

614


how many sql dml commands are supported by 'mysql'? : Sql dba

559


How can we avoid duplicating records in a query?

552


What are primary key and foreign key and how they work?

537


What is 19 null in sql?

521






How do I count records in sql?

503


Which is better join or inner query?

506


What are data types in pl sql?

548


Does sql*plus also have a pl/sql engine?

550


Can you join a table to itself?

530


what are local and global variables and their differences? : Sql dba

524


Can we join two tables without common column?

498


Can we use view in stored procedure?

495


Can two tables have same primary key?

525


What are the two characteristics of a primary key?

479