Please let me know if UNION ALL and Natural Join does the
same operation and are same...
Answers were Sorted based on User's Feedback
Answer / vasanth
Hi All....!
Natural join is the same as an equi join on (emp.deptno =
dept.deptno).
Natural joins may cause problems if columns are added or
renamed. Also, no more than two tables can be joined using
this method. So, it is best to avoid natural joins as far
as possible.
If you will come to UNION ALL.
UNION ALL query allows you to combine the result sets of 2
or more "select" queries. It returns all rows (even if the
row exists in more than one of the "select" statements.
Each SQL statement within the UNION ALL query must have the
same number of fields in the result sets with similar data
types.
For Example :-
select field1, field2, . field_n
from tables
UNION ALL
select field1, field2, . field_n
from tables;
Is This Answer Correct ? | 18 Yes | 3 No |
Answer / vasanth
Natural Join and UNION ALL won't give same results.
Is This Answer Correct ? | 15 Yes | 6 No |
Answer / vikneswaran
no,union all and natural join is not same. for example tave
two tame emp and dept
emp table
empid ename salary
1 a 1000
2 b 2000
dept table
deptid deptno
1 10
2 20
if i join this two tables
(empid = deptid)
empid ename salary deptno
1 a 1000 10
2 b 2000 20
if i union a11 this two tables
empid ename salary deptno
1 a 1000 null
2 b 2000 null
1 null null 10
2 null null 20
so join and unionall is not same
Is This Answer Correct ? | 9 Yes | 3 No |
Answer / subathra
union all: Joins the 2 selected results based on different
conditions.
Example:
select a.emp_id, b.dept_id from
emp a, dept b
where a.dept_id=b.dept_id
and a.sal < 3000
union all
select a.emp_id, b.dept_id from
emp a, dept b
where a.dept_id=b.dept_id
and a.sal > 6000
Natural Join: Establish the condition between 2 or more
tables.
Example: select a.emp_id, b.dept_id from
emp a, dept b
where a.dept_id=b.dept_id
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / g.srinivasulu
Both are not same why because in UNION ALL operator can
retrive the total number of records from the table and
NATUAL JOIN OR EQUI JOIN operator retrive the rows which
are condition must be the same and datatype of the column
names must be same...
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / swathi
no,both are not same.we are using the union all condition ,we will get the duplicate columns and which field we are selecting it get the total information of that ,But by using Natural join we can't get the all information,some columns are removed.
Is This Answer Correct ? | 0 Yes | 1 No |
Explain the rollback statement?
what is meant by forward declaration in functions?
Is join same as left join?
mention if it is possible to import data directly from t-sql commands without using sql server integration services? If yes, what are the commands? : Transact sql
How to fetch common records from two tables?
What is the difference between inner join and natural join?
how to get help information from the server? : Sql dba
What is database white box testing and black box testing?
Can we connect to postgresql using sql developer?
Which is better stored procedure or query?
How does cross join work?
What data types does pl/SQL have?