SlideShare a Scribd company logo
1 of 35
Yasir musthafa pp
yasirmusthafapp@gmail.com
www.facebook.com/yasirmusthafa
twitter.com/yasirmusthafapp
in.linkedin.com/in/yasirmusthafapp
8891396749
Sql statements ,functions and joins
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
Sql statements
• Query or command to perform a task in a
database
3 type
1. DDL
2. DML
3. DCL
DDL
Data definition language
• Create
• Alter
• Drop
• truncate
Create
Syntax in mysql
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
....
);Example
create table tbl_stock
(
pk_int_stock_id int auto_increment,
vchr_name varchar(20),
int_quantity int,
int_price int,
primary key(pk_int_stock_id)
);
Alter
Syntax in mysql
Alter table table_name modify column
column_name data_type;
Example
alter table tbl_stock modify column int_price
float;
Drop
Syntax in mysql
Drop table table_name;
Example
Drop table tbl_student;
Truncate
Syntax in mysql
Truncate table table_name;
Example
Truncate table tbl_student;
DML
Data manipulation language
• Select
• Insert
• Update
• delete
Select
Syntax in mysql
Select * from table_name;
Example
Select * from tbl_stock;
Insert
Syntax in mysql
insert into table_name values
( );
Example
insert into tbl_stock values
(NULL,"mouse",10,500,1);
Update
Syntax in mysql
Update table_name set column_name=
Example
• update tbl_stock set int_price=int_price+1.50;
delete
Syntax in mysql
Delete from table_name;
Example
Delete from tbl_stock;
Difference between delete and truncate??
DCL
Data control language
• Grant
• Revoke
• Commit
• rollback
Grant
Syntax in mysql
GRANT privilege_type ON table_name TO
‘user_name'@'localhost';
Example
GRANT select ON tbl_supplier TO
'john'@'localhost';
Revoke
Syntax in mysql
REVOKE privilege_type ON table_name FROM
‘user_name'@'localhost';
Example
REVOKE select ON tbl_supplier FROM
'suhail'@'localhost';
functions
• Built in function-perform calculation on data
1. Aggregate function
2. Scalar function
Aggregate function
• Return a single value for all the values in the
column after calculation
AVG()
Mysql syntax
Select avg(coulmn_name) from table_name;
Example
Select avg(int_salary) from employee;
COUNT(),FIRST(),LAST(),MAX(),MIN(),SUM()
Group by
• To group the result set by one or more column
• Often used in conjunction with aggregate
function
Syntax in mysql
SELECT column_name, aggregate_function(column_name)
FROM table_name
GROUP BY column_name;
Example
Select vchr_city,sum(mark) from tbl_student group by vchr_city;
Scalar function
• Return single value for each value in a column
UCASE()
Syntax in mysql
Select UCASE (column_name) from table_name;
Example
Select UCASE(first_name) from tbl_student;
• LCASE(),MID(),LEN(),ROUND(),NOW(),FORMAT()
Joins
• Used to combine rows from two or more
tables
Different joins
• inner join
• Left join
• Right join
Inner join
• Returns all rows when there is at least one
match in BOTH tables
Syntax in mysql
Select column_name(s) from table1 join table2 on
table1.column_name=table2.column_name;
Pk_int_dept_id Vchr_dept_name
1 CS
2 EC
3 EE
4 MECH
pk_int_class_id Vchr_class_name int_dept_id
1 CS100 1
2 CC300 5
3 EC100 2
4 MECH100 4
Example
select vchr_dept_name,vchr_class_name,pk_int_dept_id,int_dept_id from
tbl_dept join tbl_classes on tbl_dept.pk_int_dept_id=tbl_classes.int_dept_id;
The result set will be
Vchr_department_
name
Vchr_class_name Pk_int_dept_id int_dept_id
CS CS100 1 1
EC EC100 2 2
MECH MECH100 4 4
Left join
• returns all rows from the left table (table1), with the matching
rows in the right table (table2).
• Syntax in mysql
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
Pk_int_dept_id Vchr_dept_name
1 CS
2 EC
3 EE
4 MECH
Pk_int_class_id Vchr_class_name int_dept_id
1 CS100 1
2 EC100 2
3 CC100 5
4 MECH100 4
select vchr_dept_name,vchr_class_name,pk_int_dept_id,int_dept_id from
tbl_dept LEFT join tbl_classes on
tbl_dept.pk_int_dept_id=tbl_classes.int_dept_id;
The result will be
Vchr_dept_na
me
Vchr_class_na
me
Pk_int_dept_i
d
int_dept_id
CS CS100 1 1
EC EC100 2 2
EE NULL 3 NULL
MECH MECH100 4 4
Right join
• Return all rows from the right table, and the matched rows from the left
table
Syntax in mysql
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;
Pk_int_dept_id Vchr_dept_name
1 CS
2 EC
3 EE
4 MECH
Pk_int_class_id Vchr_class_name int_dept_name
1 CS100 1
2 EC100 2
4 MECH100 4
select vchr_dept_name,vchr_class_name,pk_int_dept_id,int_dept_id from
tbl_dept RIGHT join tbl_classes on
tbl_dept.pk_int_dept_id=tbl_classes.int_dept_id;
The result will be
Vchr_dept_na
me
Vchr_class_na
me
Pk_int_dept_i
d
int_dept_id
CS CS100 1 1
EC EC100 2 2
MECH MECH100 4 4
NULL CC100 NULL 5
Thank you
Want to learn more about programming or Looking to become a good programmer?
Are you wasting time on searching so many contents online?
Do you want to learn things quickly?
Tired of spending huge amount of money to become a Software professional?
Do an online course
@ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designed
to make a quick, good software professional out of anybody who holds a passion for coding.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
Contact Us

More Related Content

What's hot

Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statements
Vivek Singh
 
Intro to tsql unit 3
Intro to tsql   unit 3Intro to tsql   unit 3
Intro to tsql unit 3
Syed Asrarali
 
Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle Basic
Kamlesh Singh
 

What's hot (20)

Day 1b R structures objects.pptx
Day 1b   R structures   objects.pptxDay 1b   R structures   objects.pptx
Day 1b R structures objects.pptx
 
Sql delete, truncate, drop statements
Sql delete, truncate, drop statementsSql delete, truncate, drop statements
Sql delete, truncate, drop statements
 
Day 5b statistical functions.pptx
Day 5b   statistical functions.pptxDay 5b   statistical functions.pptx
Day 5b statistical functions.pptx
 
SQL Pattern Matching – should I start using it?
SQL Pattern Matching – should I start using it?SQL Pattern Matching – should I start using it?
SQL Pattern Matching – should I start using it?
 
Chapter9 more on database and sql
Chapter9 more on database and sqlChapter9 more on database and sql
Chapter9 more on database and sql
 
Data Types and Structures in R
Data Types and Structures in RData Types and Structures in R
Data Types and Structures in R
 
Dml and ddl
Dml and ddlDml and ddl
Dml and ddl
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Ddl & dml commands
Ddl & dml commandsDdl & dml commands
Ddl & dml commands
 
3 R Tutorial Data Structure
3 R Tutorial Data Structure3 R Tutorial Data Structure
3 R Tutorial Data Structure
 
Data Fragementation
Data FragementationData Fragementation
Data Fragementation
 
JCL UTILITIES IEBCOPY
JCL UTILITIES IEBCOPYJCL UTILITIES IEBCOPY
JCL UTILITIES IEBCOPY
 
Intro to tsql unit 3
Intro to tsql   unit 3Intro to tsql   unit 3
Intro to tsql unit 3
 
Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle Basic
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
R code for data manipulation
R code for data manipulationR code for data manipulation
R code for data manipulation
 
SQL Queries - DML Commands
SQL Queries - DML CommandsSQL Queries - DML Commands
SQL Queries - DML Commands
 
2
22
2
 
Normalization case
Normalization caseNormalization case
Normalization case
 

Similar to Sql statement,functions and joins

Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
Reka
 
Most useful queries
Most useful queriesMost useful queries
Most useful queries
Sam Depp
 

Similar to Sql statement,functions and joins (20)

Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
Sql
SqlSql
Sql
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Sql
SqlSql
Sql
 
Mysql Ppt
Mysql PptMysql Ppt
Mysql Ppt
 
Mandatory sql functions for beginners
Mandatory sql functions for beginnersMandatory sql functions for beginners
Mandatory sql functions for beginners
 
Mysql1
Mysql1Mysql1
Mysql1
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
Mysql
MysqlMysql
Mysql
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Most useful queries
Most useful queriesMost useful queries
Most useful queries
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
SQL
SQLSQL
SQL
 
SQL
SQL SQL
SQL
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 

More from baabtra.com - No. 1 supplier of quality freshers

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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
 
+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...
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"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 ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Sql statement,functions and joins

  • 1.
  • 3. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 4. Sql statements • Query or command to perform a task in a database 3 type 1. DDL 2. DML 3. DCL
  • 5. DDL Data definition language • Create • Alter • Drop • truncate
  • 6. Create Syntax in mysql CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), .... );Example create table tbl_stock ( pk_int_stock_id int auto_increment, vchr_name varchar(20), int_quantity int, int_price int, primary key(pk_int_stock_id) );
  • 7. Alter Syntax in mysql Alter table table_name modify column column_name data_type; Example alter table tbl_stock modify column int_price float;
  • 8. Drop Syntax in mysql Drop table table_name; Example Drop table tbl_student;
  • 9. Truncate Syntax in mysql Truncate table table_name; Example Truncate table tbl_student;
  • 10. DML Data manipulation language • Select • Insert • Update • delete
  • 11. Select Syntax in mysql Select * from table_name; Example Select * from tbl_stock;
  • 12. Insert Syntax in mysql insert into table_name values ( ); Example insert into tbl_stock values (NULL,"mouse",10,500,1);
  • 13. Update Syntax in mysql Update table_name set column_name= Example • update tbl_stock set int_price=int_price+1.50;
  • 14. delete Syntax in mysql Delete from table_name; Example Delete from tbl_stock; Difference between delete and truncate??
  • 15. DCL Data control language • Grant • Revoke • Commit • rollback
  • 16. Grant Syntax in mysql GRANT privilege_type ON table_name TO ‘user_name'@'localhost'; Example GRANT select ON tbl_supplier TO 'john'@'localhost';
  • 17. Revoke Syntax in mysql REVOKE privilege_type ON table_name FROM ‘user_name'@'localhost'; Example REVOKE select ON tbl_supplier FROM 'suhail'@'localhost';
  • 18. functions • Built in function-perform calculation on data 1. Aggregate function 2. Scalar function
  • 19. Aggregate function • Return a single value for all the values in the column after calculation AVG() Mysql syntax Select avg(coulmn_name) from table_name; Example Select avg(int_salary) from employee; COUNT(),FIRST(),LAST(),MAX(),MIN(),SUM()
  • 20. Group by • To group the result set by one or more column • Often used in conjunction with aggregate function Syntax in mysql SELECT column_name, aggregate_function(column_name) FROM table_name GROUP BY column_name; Example Select vchr_city,sum(mark) from tbl_student group by vchr_city;
  • 21. Scalar function • Return single value for each value in a column UCASE() Syntax in mysql Select UCASE (column_name) from table_name; Example Select UCASE(first_name) from tbl_student; • LCASE(),MID(),LEN(),ROUND(),NOW(),FORMAT()
  • 22. Joins • Used to combine rows from two or more tables Different joins • inner join • Left join • Right join
  • 23. Inner join • Returns all rows when there is at least one match in BOTH tables Syntax in mysql Select column_name(s) from table1 join table2 on table1.column_name=table2.column_name;
  • 24. Pk_int_dept_id Vchr_dept_name 1 CS 2 EC 3 EE 4 MECH pk_int_class_id Vchr_class_name int_dept_id 1 CS100 1 2 CC300 5 3 EC100 2 4 MECH100 4 Example select vchr_dept_name,vchr_class_name,pk_int_dept_id,int_dept_id from tbl_dept join tbl_classes on tbl_dept.pk_int_dept_id=tbl_classes.int_dept_id;
  • 25. The result set will be Vchr_department_ name Vchr_class_name Pk_int_dept_id int_dept_id CS CS100 1 1 EC EC100 2 2 MECH MECH100 4 4
  • 26. Left join • returns all rows from the left table (table1), with the matching rows in the right table (table2). • Syntax in mysql SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name=table2.column_name;
  • 27. Pk_int_dept_id Vchr_dept_name 1 CS 2 EC 3 EE 4 MECH Pk_int_class_id Vchr_class_name int_dept_id 1 CS100 1 2 EC100 2 3 CC100 5 4 MECH100 4 select vchr_dept_name,vchr_class_name,pk_int_dept_id,int_dept_id from tbl_dept LEFT join tbl_classes on tbl_dept.pk_int_dept_id=tbl_classes.int_dept_id;
  • 28. The result will be Vchr_dept_na me Vchr_class_na me Pk_int_dept_i d int_dept_id CS CS100 1 1 EC EC100 2 2 EE NULL 3 NULL MECH MECH100 4 4
  • 29. Right join • Return all rows from the right table, and the matched rows from the left table Syntax in mysql SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name=table2.column_name;
  • 30. Pk_int_dept_id Vchr_dept_name 1 CS 2 EC 3 EE 4 MECH Pk_int_class_id Vchr_class_name int_dept_name 1 CS100 1 2 EC100 2 4 MECH100 4 select vchr_dept_name,vchr_class_name,pk_int_dept_id,int_dept_id from tbl_dept RIGHT join tbl_classes on tbl_dept.pk_int_dept_id=tbl_classes.int_dept_id;
  • 31. The result will be Vchr_dept_na me Vchr_class_na me Pk_int_dept_i d int_dept_id CS CS100 1 1 EC EC100 2 2 MECH MECH100 4 4 NULL CC100 NULL 5
  • 33. Want to learn more about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  • 34. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Give a feedback @ massbaab.com/baabtra Thanks in advance www.baabtra.com | www.massbaab.com |www.baabte.com
  • 35. Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com Contact Us