SlideShare uma empresa 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

Mais conteúdo relacionado

Mais procurados

Mais procurados (18)

MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
Db function
Db functionDb function
Db function
 
e computer notes - Advanced subqueries
e computer notes - Advanced subqueriese computer notes - Advanced subqueries
e computer notes - Advanced subqueries
 
e computer notes - From multiple tables
e computer notes - From multiple tablese computer notes - From multiple tables
e computer notes - From multiple tables
 
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
 
Join sql
Join sqlJoin sql
Join sql
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
MYSQL using set operators
MYSQL using set operatorsMYSQL using set operators
MYSQL using set operators
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
 
Chapter9 more on database and sql
Chapter9 more on database and sqlChapter9 more on database and sql
Chapter9 more on database and sql
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
Les04
Les04Les04
Les04
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
7. Using Sub Queries
7. Using Sub Queries7. Using Sub Queries
7. Using Sub Queries
 
MYSql manage db
MYSql manage dbMYSql manage db
MYSql manage db
 
SQL
SQLSQL
SQL
 
Sql modifying data - MYSQL part I
Sql modifying data - MYSQL part ISql modifying data - MYSQL part I
Sql modifying data - MYSQL part I
 
Ms excel 2003 intermediate
Ms excel 2003 intermediateMs excel 2003 intermediate
Ms excel 2003 intermediate
 

Destaque

WEKA: Output Knowledge Representation
WEKA: Output Knowledge RepresentationWEKA: Output Knowledge Representation
WEKA: Output Knowledge RepresentationDataminingTools Inc
 
Procedures And Functions in Matlab
Procedures And Functions in MatlabProcedures And Functions in Matlab
Procedures And Functions in MatlabDataminingTools Inc
 
Huidige status van de testtaal TTCN-3
Huidige status van de testtaal TTCN-3Huidige status van de testtaal TTCN-3
Huidige status van de testtaal TTCN-3Erik Altena
 
Cinnamonhotel saigon 2013_01
Cinnamonhotel saigon 2013_01Cinnamonhotel saigon 2013_01
Cinnamonhotel saigon 2013_01cinnamonhotel
 
Introduction To Programming in Matlab
Introduction To Programming in MatlabIntroduction To Programming in Matlab
Introduction To Programming in MatlabDataminingTools Inc
 
MS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With FunctionsMS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With FunctionsDataminingTools Inc
 
Excel Datamining Addin Intermediate
Excel Datamining Addin IntermediateExcel Datamining Addin Intermediate
Excel Datamining Addin IntermediateDataminingTools Inc
 
DataKraft - Powerful No-Coding Platform for Business Applications
DataKraft - Powerful No-Coding Platform for Business ApplicationsDataKraft - Powerful No-Coding Platform for Business Applications
DataKraft - Powerful No-Coding Platform for Business ApplicationsTibbs Pereira
 

Destaque (20)

WEKA: Output Knowledge Representation
WEKA: Output Knowledge RepresentationWEKA: Output Knowledge Representation
WEKA: Output Knowledge Representation
 
Procedures And Functions in Matlab
Procedures And Functions in MatlabProcedures And Functions in Matlab
Procedures And Functions in Matlab
 
XL-MINER:Prediction
XL-MINER:PredictionXL-MINER:Prediction
XL-MINER:Prediction
 
Txomin Hartz Txikia
Txomin Hartz TxikiaTxomin Hartz Txikia
Txomin Hartz Txikia
 
LISP: Declarations In Lisp
LISP: Declarations In LispLISP: Declarations In Lisp
LISP: Declarations In Lisp
 
Huidige status van de testtaal TTCN-3
Huidige status van de testtaal TTCN-3Huidige status van de testtaal TTCN-3
Huidige status van de testtaal TTCN-3
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
Cinnamonhotel saigon 2013_01
Cinnamonhotel saigon 2013_01Cinnamonhotel saigon 2013_01
Cinnamonhotel saigon 2013_01
 
Data Applied:Tree Maps
Data Applied:Tree MapsData Applied:Tree Maps
Data Applied:Tree Maps
 
Ontwikkeling In Eigen Handen Nl Web
Ontwikkeling In Eigen Handen Nl WebOntwikkeling In Eigen Handen Nl Web
Ontwikkeling In Eigen Handen Nl Web
 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
 
Introduction To Programming in Matlab
Introduction To Programming in MatlabIntroduction To Programming in Matlab
Introduction To Programming in Matlab
 
MS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With FunctionsMS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With Functions
 
R Datatypes
R DatatypesR Datatypes
R Datatypes
 
Excel Datamining Addin Intermediate
Excel Datamining Addin IntermediateExcel Datamining Addin Intermediate
Excel Datamining Addin Intermediate
 
DataKraft - Powerful No-Coding Platform for Business Applications
DataKraft - Powerful No-Coding Platform for Business ApplicationsDataKraft - Powerful No-Coding Platform for Business Applications
DataKraft - Powerful No-Coding Platform for Business Applications
 
R Statistics
R StatisticsR Statistics
R Statistics
 
Matlab: Discrete Linear Systems
Matlab: Discrete Linear SystemsMatlab: Discrete Linear Systems
Matlab: Discrete Linear Systems
 
Data Applied: Association
Data Applied: AssociationData Applied: Association
Data Applied: Association
 
Control Statements in Matlab
Control Statements in  MatlabControl Statements in  Matlab
Control Statements in Matlab
 

Semelhante a Oracle: Joins

Semelhante a Oracle: Joins (20)

Query
QueryQuery
Query
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL Fundamentals
SQL FundamentalsSQL Fundamentals
SQL Fundamentals
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Sql Queries
Sql QueriesSql Queries
Sql Queries
 
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
 
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
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
Interview Questions.pdf
Interview Questions.pdfInterview Questions.pdf
Interview Questions.pdf
 

Mais de DataminingTools Inc

AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceDataminingTools Inc
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web miningDataminingTools Inc
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataDataminingTools Inc
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsDataminingTools Inc
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisDataminingTools Inc
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technologyDataminingTools Inc
 

Mais de DataminingTools Inc (20)

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
 

Último

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Último (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

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