SlideShare une entreprise Scribd logo
1  sur  14
1 Using ORACLE® Retrieving data from multiple tables(joins) Sub-queries and Set operators
2 JOINS
3 USES OF JOINS
4 EQUI JOIN Equi Join is a simple SQL join condition that uses EQUAL sign as the comparison operator  Syntax: SELECT col1,col2,col3 FROM table1,table2 WHERE table1.col1=table2.col1; EQUI JOIN on product_master and customer_master tables: SELECT prod_name,prod_stock,quantity,deliver_by                     FROM product_master,customer_master  WHERE order_id=prod_id;  By this we can have an approximation of the quantity and date of products that need to be shipped out.
5 OUTER JOINS OUTER join condition returns all rows from both tables which satisfy the join condition along with rows which do not satisfy the join condition from one of the tables. The SQL outer join operator in Oracle is ( + ) and is used on one side of the join condition only. Syntax: SELECT col1,col2 FROM table1,table2 WHERE  table1.col1 (+) = table2.col1; OUTER JOIN on product_master table and customer_master: SELECTp.prod_id, p.prod_name, o.order_id, o.quantity FROM customer_master o, product_master p WHEREp.prod_id (+)= o.order_id  ;
6 CARTESIAN JOINS If a SQL join condition is omitted or if it is invalid the join operation will result in a Cartesian product. The Cartesian product returns a number of rows equal to the product of all rows in all the tables being joined. For example, if the first table has 20 rows and the second table has 10 rows, the result will be 20 * 10, or 200 rows. This query takes a long time to execute. SYNTAX: SELECT col1,col2 FROM table1,table2; CARTESIAN JOIN on product_master and customer_master: SELECTorder_id,prod_name FROMcustomer_master,product_master; Here  each row from customer_master will be  Mapped to each row of product_master.Here the This query contains 50 rows only 10 rows are  Shown in the figure
7 SELF JOINS A Self join is the type of SQL join where we join a particular table to itself. Here it is necessary to ensure that the join statement defines an ALIAS name for both the copies of the tables to avoid column ambiguity  Syntax for Table Alias: SELECTs.first_nameFROMstudent_details s;            In this query alias s is defined for the table student_details and the column first_name is selected from the table. Self Join on Course table: SELECTa.course_nameASCOURSE,b.course_nameAS PREREQUSITE_COURSE FROMcourse_ma,course_m b WHEREa.pre_course=b.course_id;
8 NATURAL/CARTESIAN  JOINS CARTESIAN JOIN is also known as NATURAL JOIN .The output of this join can be filtered using the WHERE clause. SELECTprod_ID,prod_name ,order_id,quantity FROM product_master NATURAL JOIN customer_master WHERE prod_name LIKE ('teak%') AND quantity=10;
9 SUBQUERY IN SQL A Subquery is also called as an Inner query or a Nested query. It is a query inside another query. A subquery is usually added in the WHERE Clause of the SQL statement. Most of the time, a subquery is used when we know how to search for a value using a SELECT statement, but do not know the exact value. Subqueries are an alternate way of returning data from multiple tables Subqueries can be used with the following sql statements along with the comparision operators like =, <, >, >=, <= etc. Usually, a subquery should return only one record, but sometimes it can also return multiple records when used with operators like IN, NOT IN in the where clause. 			 SELECT column….. FROM tablename WHERE SUBQUERY rown ……			The result set of the 			subquery act as the condition set for 				the main query 												 row1 The SELECT subquery statement
10 SET OPERATORS Set operators combine the results of two component queries into a single result. Queries containing set operators are called compound queries. The Set Operators in SQL are:
11 SET OPERATOR - UNION The UNION set operator is used to combine multiple subqueries and their outputs. The UNION clause merges the outputs of two or more subqueries into one in such a way that the  Result set = Records only in query 1 + Records only in query 2 + A single set of records 	  	    common to both query 1 and query 2 . Example: SELECT * FROM InfoTable  WHERE  age = 40			 UNION SELECT * FROM InfoTable  WHERE age = 45;  Result Set Records  from  Query 1 Records  from  Query 2 Query 1 Query 2 Records common to both Queries
12 SET OPERATOR - INTERSECT The INTERSECT set operator is used to combine multiple subqueries and their outputs. The INTERSECT clause merges the outputs of two or more subqueries into one in such a way that the  Result set = A single set of records common to both query 1 and query 2 . Example: SELECT * FROM InfoTable  WHERE  age = 40			 INTERSECT SELECT * FROM InfoTable  WHERE age = 45;  Result Set Records  from  Query 1 Records  from  Query 2 Query 1 Query 2 Records common to both Queries
13 SET OPERATOR - MINUS The MINUS set operator is used to combine multiple subqueries and their outputs. The MINUS clause filters records from Second Query and common records and displays the remaining records. Result set = Records only in query 1 – [ Records only in query 2 + A single set of records 	  	    common to both query 1 and query 2 ]. Example: SELECT * FROM InfoTable  WHERE  age = 40			 MINUS SELECT * FROM InfoTable  WHERE age = 45;  Result Set Records  from  Query 1 Records  from  Query 2 Query 1 Query 2 Records common to both Queries and from Query 2 not included in the result set
THANK YOU 14 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit:   www.dataminingtools.net

Contenu connexe

Tendances (20)

Oracle Database Trigger
Oracle Database TriggerOracle Database Trigger
Oracle Database Trigger
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Trigger
TriggerTrigger
Trigger
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joins
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
Single row functions
Single row functionsSingle row functions
Single row functions
 
SQL UNION
SQL UNIONSQL UNION
SQL UNION
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
DML Commands
DML CommandsDML Commands
DML Commands
 
SQL
SQLSQL
SQL
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 

En vedette

Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joinsredro
 
ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...
ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...
ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...Michael M David
 
Sql Patterns
Sql PatternsSql Patterns
Sql Patternsphanleson
 
oracle joins and sql joins
oracle joins and sql joinsoracle joins and sql joins
oracle joins and sql joinsshripal singh
 
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joinsmysqlops
 
Corba and-java
Corba and-javaCorba and-java
Corba and-javaafreen58
 
Step By Step How To Install Oracle XE
Step By Step How To Install Oracle XEStep By Step How To Install Oracle XE
Step By Step How To Install Oracle XEAchmad Solichin
 
Tutorial Instalisasi Oracle 10g dan Setting User
Tutorial Instalisasi Oracle 10g dan Setting UserTutorial Instalisasi Oracle 10g dan Setting User
Tutorial Instalisasi Oracle 10g dan Setting UserImam Halim Mursyidin
 
Intro oracle10gexpress
Intro oracle10gexpressIntro oracle10gexpress
Intro oracle10gexpressjatin Sareen
 
IBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash JoinIBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash JoinAjay Gupte
 
Oracle intro to designer abridged
Oracle intro to designer abridgedOracle intro to designer abridged
Oracle intro to designer abridgedFITSFSd
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)Ehtisham Ali
 
Time-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesTime-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesChema Alonso
 
Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beansRaghu nath
 

En vedette (20)

Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joins
 
ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...
ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...
ANSI SQL Transparent Multipath Hierarchical Structured Data Processing for Re...
 
Sql Patterns
Sql PatternsSql Patterns
Sql Patterns
 
Flash Presentation
Flash PresentationFlash Presentation
Flash Presentation
 
oracle joins and sql joins
oracle joins and sql joinsoracle joins and sql joins
oracle joins and sql joins
 
Something about oracle joins
Something about oracle joinsSomething about oracle joins
Something about oracle joins
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
 
Hash join
Hash joinHash join
Hash join
 
Corba and-java
Corba and-javaCorba and-java
Corba and-java
 
Join operation
Join operationJoin operation
Join operation
 
Step By Step How To Install Oracle XE
Step By Step How To Install Oracle XEStep By Step How To Install Oracle XE
Step By Step How To Install Oracle XE
 
Tutorial Instalisasi Oracle 10g dan Setting User
Tutorial Instalisasi Oracle 10g dan Setting UserTutorial Instalisasi Oracle 10g dan Setting User
Tutorial Instalisasi Oracle 10g dan Setting User
 
Intro oracle10gexpress
Intro oracle10gexpressIntro oracle10gexpress
Intro oracle10gexpress
 
Intro to Application Express
Intro to Application ExpressIntro to Application Express
Intro to Application Express
 
IBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash JoinIBM Informix Database SQL Set operators and ANSI Hash Join
IBM Informix Database SQL Set operators and ANSI Hash Join
 
Oracle intro to designer abridged
Oracle intro to designer abridgedOracle intro to designer abridged
Oracle intro to designer abridged
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)
 
Time-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesTime-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy Queries
 
Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
 
Oracle database introduction
Oracle database introductionOracle database introduction
Oracle database introduction
 

Similaire à Oracle: Joins

Similaire à Oracle: Joins (20)

Query
QueryQuery
Query
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL Fundamentals
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Chapter9 more on database and sql
Chapter9 more on database and sqlChapter9 more on database and sql
Chapter9 more on database and sql
 
Sql Queries
Sql QueriesSql Queries
Sql Queries
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
Computer Science:Sql Set Operation
Computer Science:Sql Set OperationComputer Science:Sql Set Operation
Computer Science:Sql Set Operation
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 
Assignment 4
Assignment 4Assignment 4
Assignment 4
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Babitha2.mysql
Babitha2.mysqlBabitha2.mysql
Babitha2.mysql
 
Babitha2 Mysql
Babitha2 MysqlBabitha2 Mysql
Babitha2 Mysql
 
e computer notes - Advanced subqueries
e computer notes - Advanced subqueriese computer notes - Advanced subqueries
e computer notes - Advanced subqueries
 
MYSQL using set operators
MYSQL using set operatorsMYSQL using set operators
MYSQL using set operators
 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptx
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 

Plus de oracle content

Plus de oracle content (13)

Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Oracle : DML
Oracle : DMLOracle : DML
Oracle : DML
 
Oracle: Programs
Oracle: ProgramsOracle: Programs
Oracle: Programs
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Oracle: Control Structures
Oracle:  Control StructuresOracle:  Control Structures
Oracle: Control Structures
 
Oracle: Dw Design
Oracle: Dw DesignOracle: Dw Design
Oracle: Dw Design
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle Warehouse
Oracle WarehouseOracle Warehouse
Oracle Warehouse
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Oracle: New Plsql
Oracle: New PlsqlOracle: New Plsql
Oracle: New Plsql
 
Oracle: Fundamental Of Dw
Oracle: Fundamental Of DwOracle: Fundamental Of Dw
Oracle: Fundamental Of Dw
 

Dernier

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Oracle: Joins

  • 1. 1 Using ORACLE® Retrieving data from multiple tables(joins) Sub-queries and Set operators
  • 3. 3 USES OF JOINS
  • 4. 4 EQUI JOIN Equi Join is a simple SQL join condition that uses EQUAL sign as the comparison operator Syntax: SELECT col1,col2,col3 FROM table1,table2 WHERE table1.col1=table2.col1; EQUI JOIN on product_master and customer_master tables: SELECT prod_name,prod_stock,quantity,deliver_by FROM product_master,customer_master WHERE order_id=prod_id; By this we can have an approximation of the quantity and date of products that need to be shipped out.
  • 5. 5 OUTER JOINS OUTER join condition returns all rows from both tables which satisfy the join condition along with rows which do not satisfy the join condition from one of the tables. The SQL outer join operator in Oracle is ( + ) and is used on one side of the join condition only. Syntax: SELECT col1,col2 FROM table1,table2 WHERE table1.col1 (+) = table2.col1; OUTER JOIN on product_master table and customer_master: SELECTp.prod_id, p.prod_name, o.order_id, o.quantity FROM customer_master o, product_master p WHEREp.prod_id (+)= o.order_id ;
  • 6. 6 CARTESIAN JOINS If a SQL join condition is omitted or if it is invalid the join operation will result in a Cartesian product. The Cartesian product returns a number of rows equal to the product of all rows in all the tables being joined. For example, if the first table has 20 rows and the second table has 10 rows, the result will be 20 * 10, or 200 rows. This query takes a long time to execute. SYNTAX: SELECT col1,col2 FROM table1,table2; CARTESIAN JOIN on product_master and customer_master: SELECTorder_id,prod_name FROMcustomer_master,product_master; Here each row from customer_master will be Mapped to each row of product_master.Here the This query contains 50 rows only 10 rows are Shown in the figure
  • 7. 7 SELF JOINS A Self join is the type of SQL join where we join a particular table to itself. Here it is necessary to ensure that the join statement defines an ALIAS name for both the copies of the tables to avoid column ambiguity Syntax for Table Alias: SELECTs.first_nameFROMstudent_details s; In this query alias s is defined for the table student_details and the column first_name is selected from the table. Self Join on Course table: SELECTa.course_nameASCOURSE,b.course_nameAS PREREQUSITE_COURSE FROMcourse_ma,course_m b WHEREa.pre_course=b.course_id;
  • 8. 8 NATURAL/CARTESIAN JOINS CARTESIAN JOIN is also known as NATURAL JOIN .The output of this join can be filtered using the WHERE clause. SELECTprod_ID,prod_name ,order_id,quantity FROM product_master NATURAL JOIN customer_master WHERE prod_name LIKE ('teak%') AND quantity=10;
  • 9. 9 SUBQUERY IN SQL A Subquery is also called as an Inner query or a Nested query. It is a query inside another query. A subquery is usually added in the WHERE Clause of the SQL statement. Most of the time, a subquery is used when we know how to search for a value using a SELECT statement, but do not know the exact value. Subqueries are an alternate way of returning data from multiple tables Subqueries can be used with the following sql statements along with the comparision operators like =, <, >, >=, <= etc. Usually, a subquery should return only one record, but sometimes it can also return multiple records when used with operators like IN, NOT IN in the where clause. SELECT column….. FROM tablename WHERE SUBQUERY rown …… The result set of the subquery act as the condition set for the main query row1 The SELECT subquery statement
  • 10. 10 SET OPERATORS Set operators combine the results of two component queries into a single result. Queries containing set operators are called compound queries. The Set Operators in SQL are:
  • 11. 11 SET OPERATOR - UNION The UNION set operator is used to combine multiple subqueries and their outputs. The UNION clause merges the outputs of two or more subqueries into one in such a way that the Result set = Records only in query 1 + Records only in query 2 + A single set of records common to both query 1 and query 2 . Example: SELECT * FROM InfoTable WHERE age = 40 UNION SELECT * FROM InfoTable WHERE age = 45; Result Set Records from Query 1 Records from Query 2 Query 1 Query 2 Records common to both Queries
  • 12. 12 SET OPERATOR - INTERSECT The INTERSECT set operator is used to combine multiple subqueries and their outputs. The INTERSECT clause merges the outputs of two or more subqueries into one in such a way that the Result set = A single set of records common to both query 1 and query 2 . Example: SELECT * FROM InfoTable WHERE age = 40 INTERSECT SELECT * FROM InfoTable WHERE age = 45; Result Set Records from Query 1 Records from Query 2 Query 1 Query 2 Records common to both Queries
  • 13. 13 SET OPERATOR - MINUS The MINUS set operator is used to combine multiple subqueries and their outputs. The MINUS clause filters records from Second Query and common records and displays the remaining records. Result set = Records only in query 1 – [ Records only in query 2 + A single set of records common to both query 1 and query 2 ]. Example: SELECT * FROM InfoTable WHERE age = 40 MINUS SELECT * FROM InfoTable WHERE age = 45; Result Set Records from Query 1 Records from Query 2 Query 1 Query 2 Records common to both Queries and from Query 2 not included in the result set
  • 14. THANK YOU 14 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit: www.dataminingtools.net