SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
Sql join
Sql  joinSql  join
Sql join
 
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
 
Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle Sql
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
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
 
Mysql
MysqlMysql
Mysql
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
SQL select clause
SQL select clauseSQL select clause
SQL select clause
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
 
Mysql joins
Mysql joinsMysql joins
Mysql joins
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 

Destacado

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
 

Destacado (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
 
SQL UNION
SQL UNIONSQL UNION
SQL UNION
 
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
 

Similar a Oracle: Joins

Similar a 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
 
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
 
Prabu's sql quries
Prabu's sql quries Prabu's sql quries
Prabu's sql quries
 

Más de oracle content

Más 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
 

Último

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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