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 |
What is sql select statement?
What is keys and its types?
What does “select count(1) from tab” result?
what is sql optimization
Why do we need cursors in pl sql?
What is the difference between subquery and correlated query?
Can I call a procedure inside a function?
1. how to use the check option constraints in sql query..? 2.how to add data in a complex query ? 3.is it possible to use commit or rollback or savepoint in triggers...if not why please explain with examples...? 4.what is the difference between meterialized view and normal view..how to create materialized view and how to use it..? 5.what is varray...? what is the advantage of the varray ? please expalin with a simpel example..i want to load into a table (student no and name and his marks..) please give example.. 6.what are the bulk bind exceptions...how to use bulk bind and how to use bulk collect..please explain with example... 7.what is for update of and where current of ...? 8 what is the use of nowait ? 9.please give an example for nocopy in a simple plsql query 10.create an index in a table...tellme how to use the index in a where clause to do performance tunning...
What is difference between cursor and ref cursor?
source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000 delhi hyd 1000 bangalore hyd 800 Here chennai to bangalore and bangalore to chennai is same distance. and hyd and delhi also same criteria. Based on the distance i want to display only one row using sql query?
how many triggers are allowed in mysql table? : Sql dba
write a procedure to print a statement or number not using "dbms_output.put_line" package.write a procedure instead of it using procdure name as "print" ex:- declare a number:=2; begin print(a); end; /* when U type above procedure 2 have to should be printed*/
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)