SlideShare a Scribd company logo
NikhilDevS.B
nikhildevsb@gmail.com
www.facebook.com/nikhildevsb
TwitterProfile
www.linkedin.com/nikhildevsb
Typing speed: 24 wpm.
SQL STATEMENTS , FUNCTIONS AND JOINS
Disclaimer: This presentation is prepared by trainees of
baabtra.com as a part of mentoring program. This is not
official document of baabtra.com – Mentoring Partner
SQL
Structured Query Language
SQL is Special purpose programming language designed
for managing data held in Relational Data Base
Management System(RDBMS)
SQL STATEMENTS
• Data Definition Language (DDL)
- Define database structure/schema.
• Data Manipulation Language (DML)
-Manipulation on table data.
Query one or more tables.
• Data Control Language (DCL)
-Set database permissions and privileges.
DDL Statements are :
CRAETE
ALTER
DROP
TRUNCATE
DML Statements are :
INSERT
SELECT
UPDATE
DELETE
DCL Statements
GRANT
ROLLBACK
REVOKE
Tables in SQL
PName Price Category Manufacturer
Gizmo $19.99 Gadgets GizmoWorks
Powergizmo $29.99 Gadgets GizmoWorks
SingleTouch $149.99 Photography Canon
MultiTouch $203.99 Household Hitachi
Product
Attribute/field/
column
Table name
Tuples or rows
DDL Commands
• CREATE - To create objects in data base.
o CREATE DATABASE <database name>;
E.g. CREATE DATABASE db_student;
o CREATE TABLE tablename
(
field1 datatype,
field2 datatype
);
E.g. CREATE TABLE tbl_student(vchr_name varchar(20),int_roll int);
vchr_name int_roll
NULL NULL
• ALTER – Alter the structure of database. i.e., to add or drop
columns on existing table.
ALTER TABLE tablename ADD column datatype;//add column
ALTER TABLE tablename DROP column; //delete a column
E.g. ALTER TABLE tbl_student ADD int_mark int; //added new
column mark of
type integer
E.g. ALTER TABLE tbl_student DROP int_mark; //deleted mark
vchr_name int_roll int_mark
NULL NULL NULL
• TRUNCATE – To remove all records from table.
TRUNCATE TABLE tablename;
E.g. TRUNCATE TABLE tbl_student;
• RENAME - to rename a table
RENAME TABLE oldname TO newname’;
E.g. RENAME TABLE tbl_student TO tbl_studentrecord;
DML Commands
• INSERT – Add data into the table.
insert into table_name values(data1,data2,...);
insert into tbl_student values(‘john’, 11);
tbl_student
vchr_name int_roll
john 11
• UPDATE – to update a value in a table.
UPDATE table_name SET column_name=value WHERE condition.
E.g. UPDATE tbl_student set vchr_name=‘james’ where chr_name=‘john’;
vchr_name int_roll
steve 10
james 11
vchr_name int_roll
steve 10
john 11
Before update
After update
• DELETE – to delete a row from table.
DELETE FROM tablename ;
DELETE from tbl_student where chr_name=‘james’;
pk_id vchr_name int_roll
1 steve 10
2 james 11
Before deletion
After deletion
pk_id vchr_name int_roll
1 steve 10
• SELECT – Retrieve data from database.
SELECT column FROM tablename;
E.g1. SELECT * FROM tbl_student; //gives all columns of table
pk_id vchr_name int_roll
1 steve 10
2 James 11
E.g2. SELECT pk_id,vchr_name FROM tbl_student; //gives
specified columns of table
pk_id vchr_name
1 steve
2 james
Functions
1.Aggregate function
2.Scalar functions
Aggregate Functions
Function that returns a single value, calculated from values
in column.
• SUM() – returns sum of column.
• COUNT() – returns number of rows.
• AVG() – returns average value of column.
• MIN() – returns smallest value of column.
• MAX() – returns largest value of column.
• LAST() – returns the last value.
• FIRST() – returns the first value.
Use of aggregate functions.
SELECT avg(emp_count), sum(emp_count), max(emp_count)
min(emp_count), count(emp_count) from tbl_employee;
brnch_num brnch_name region_num emp_count
108 New york 100 10
110 Boston 100 6
21 Chicago 200 5
404 San Diego 400 6
415 San jose 400 3
avg(emp_count) sum(emp_count) max(emp_count) min(emp_count) count(emp_count)
6 30 10 3 5
Scalar Functions
Function that returns a single value, based on input value.
• UCASE() – converts a field to upper case.
• LCASE() - converts a field to lower case.
• LEN() – returns the length of a text filed.
• ROUND() – rounds a numeric field to number of decimal
specified
SELECT UCASE(column_name) FROM table_name;
JOIN OPERATION
Combine rows from two or more tables, based on a common
field between them.
• INNER JOIN (SIMPLE JOIN OR JOIN) – Returns rows when there is a
match in both tables
• OUTER JOIN –Returns all the rows of both table whether it has matched
or not
-LEFT OUTER JOIN (LEFT JOIN) – Returns all rows from left
table and matched rows from right table.
- RIGHT OUTER JOIN (RIGHT JOIN)- Returns all rows from
right table and matched rows from left table
Pk_emp_id vchr_emp_name vchr_company
1 James Dell
2 John Sony
3 Albert Hp
Pk_desig_id vchr_desig
1 System
engineer
2 Tester
4 Tech support
Tbl_emp Tbl_empdesig
SELECT * FROM tbl_emp JOIN tbl_empdesig on
tbl_emp.pk_emp_id=tbl_empdesig.pk_desig_id
Pk_emp_id vchr_emp_name vchr_company Pk_desig_id vchr_desig
1 James Delll 1 System engineer
2 john Sony 2 Tester
E.g. JOIN
Common value
LEFT OUTER JOIN
Pk_emp_id vchr_emp_name Chr_company
1 James Dell
2 John Sony
3 Albert Hp
Pk_desig_id vchr_desig
1 System
engineer
2 Tester
4 Tech support
Tbl_emp Tbl_empdesig
SELECT * FROM tbl_emp LEFT JOIN tbl_empdesig on
tbl_emp.pk_emp_id=tbl_empdesig.pk_desig_id
Pk_emp_id vchr_emp_name vchr_company Pk_desig_id vchr_desig
1 James Delll 1 System engineer
2 john Sony 2 Tester
3 Albert Hp Null null
RIGHT OUTER JOIN
Pk_emp_id vchr_emp_name vchr_company
1 James Dell
2 John Sony
3 Albert Hp
Pk_desig_id vchr_desig
1 System
engineer
2 Tester
4 Tech support
Tbl_emp Tbl_empdesig
SELECT * FROM tbl_emp RIGHT JOIN tbl_empdesig on
tbl_emp.pk_emp_id=tbl_empdesig.pk_desig_id
Pk_emp_id vchr_emp_name vchr_company Pk_desig_id vchr_desig
1 James Delll 1 System engineer
2 john Sony 2 Tester
null null null 4 Tech suport
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

Finishing Complete
Finishing CompleteFinishing Complete
Finishing CompleteNabeel Shan
 
Needle Loop & Sinker Loop
Needle Loop & Sinker LoopNeedle Loop & Sinker Loop
Needle Loop & Sinker LoopAmirul Eahsan
 
Application of computer in textile manufacturing
Application of computer in textile manufacturingApplication of computer in textile manufacturing
Application of computer in textile manufacturing
Md Nurunnabi
 
Feeder stripe, Engineering stripe and Auto stripe mechanism
Feeder stripe, Engineering stripe and Auto stripe mechanismFeeder stripe, Engineering stripe and Auto stripe mechanism
Feeder stripe, Engineering stripe and Auto stripe mechanism
Azmir Latif Beg
 
Fabric Spreading
Fabric SpreadingFabric Spreading
Fabric Spreading
Ashenafi Solomon
 
Knitting and defects
Knitting and defectsKnitting and defects
Knitting and defects
RasminThahaniZ
 
Various tappet loom parts with function
Various tappet loom parts with functionVarious tappet loom parts with function
Various tappet loom parts with function
Md Nurunnabi
 
Fabric structure and design
Fabric structure and designFabric structure and design
Fabric structure and design
Fuad Ahmed
 
In process Inspection.
In process Inspection.In process Inspection.
In process Inspection.
student at textile engineering
 
Knitted fabrics and their properties
Knitted fabrics and their propertiesKnitted fabrics and their properties
Knitted fabrics and their properties
tawfik_hussein
 
Derivatives of single jersey structures
Derivatives of single jersey structuresDerivatives of single jersey structures
Derivatives of single jersey structures
JaforJr
 
Autoconer 21C
Autoconer 21CAutoconer 21C
Autoconer 21C
Madan Badariya
 
Fabric spreading
Fabric spreadingFabric spreading
Fabric spreading
pollobks
 
Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)
Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)
Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)
MohammadAshraful4
 
jaquard erection and jacquard commissioning rupesh
jaquard erection and jacquard commissioning rupeshjaquard erection and jacquard commissioning rupesh
jaquard erection and jacquard commissioning rupesh
Multi Addiction
 
Mechanical Bonding
Mechanical BondingMechanical Bonding
Mechanical Bonding
ctkiaora81
 

What's hot (20)

DENIM MANUFACTURING
DENIM MANUFACTURINGDENIM MANUFACTURING
DENIM MANUFACTURING
 
Finishing Complete
Finishing CompleteFinishing Complete
Finishing Complete
 
Compactor
CompactorCompactor
Compactor
 
Needle Loop & Sinker Loop
Needle Loop & Sinker LoopNeedle Loop & Sinker Loop
Needle Loop & Sinker Loop
 
Application of computer in textile manufacturing
Application of computer in textile manufacturingApplication of computer in textile manufacturing
Application of computer in textile manufacturing
 
Feeder stripe, Engineering stripe and Auto stripe mechanism
Feeder stripe, Engineering stripe and Auto stripe mechanismFeeder stripe, Engineering stripe and Auto stripe mechanism
Feeder stripe, Engineering stripe and Auto stripe mechanism
 
Air flow dyeing machine
Air flow dyeing machineAir flow dyeing machine
Air flow dyeing machine
 
Fabric Spreading
Fabric SpreadingFabric Spreading
Fabric Spreading
 
Knitting and defects
Knitting and defectsKnitting and defects
Knitting and defects
 
Various tappet loom parts with function
Various tappet loom parts with functionVarious tappet loom parts with function
Various tappet loom parts with function
 
FABRICATION
FABRICATIONFABRICATION
FABRICATION
 
Fabric structure and design
Fabric structure and designFabric structure and design
Fabric structure and design
 
In process Inspection.
In process Inspection.In process Inspection.
In process Inspection.
 
Knitted fabrics and their properties
Knitted fabrics and their propertiesKnitted fabrics and their properties
Knitted fabrics and their properties
 
Derivatives of single jersey structures
Derivatives of single jersey structuresDerivatives of single jersey structures
Derivatives of single jersey structures
 
Autoconer 21C
Autoconer 21CAutoconer 21C
Autoconer 21C
 
Fabric spreading
Fabric spreadingFabric spreading
Fabric spreading
 
Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)
Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)
Apparel Manufacturing I (Part 1)- mid term(green university of bangladesh)
 
jaquard erection and jacquard commissioning rupesh
jaquard erection and jacquard commissioning rupeshjaquard erection and jacquard commissioning rupesh
jaquard erection and jacquard commissioning rupesh
 
Mechanical Bonding
Mechanical BondingMechanical Bonding
Mechanical Bonding
 

Similar to Sql statements function join

Sql 
statements , functions & joins
Sql 
statements , functions  &  joinsSql 
statements , functions  &  joins
Sql 
statements , functions & joins
baabtra.com - No. 1 supplier of quality freshers
 
Lab
LabLab
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
Sharad Dubey
 
Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)
Muhammed Thanveer M
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
MUHAMMADANSAR76
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
Om Vikram Thapa
 
Creating a database
Creating a databaseCreating a database
Creating a databaseRahul Gupta
 
Dbms
DbmsDbms
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
BCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfBCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdf
KeerthanaP37
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
suriyae1
 

Similar to Sql statements function join (20)

Sql
SqlSql
Sql
 
Sql 
statements , functions & joins
Sql 
statements , functions  &  joinsSql 
statements , functions  &  joins
Sql 
statements , functions & joins
 
Lab
LabLab
Lab
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
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
 
Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
 
Sql statement,functions and joins
Sql statement,functions and joinsSql statement,functions and joins
Sql statement,functions and joins
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
 
Creating a database
Creating a databaseCreating a database
Creating a database
 
Dbms
DbmsDbms
Dbms
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
BCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfBCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdf
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Introduction to mysql part 2
Introduction to mysql part 2Introduction to mysql part 2
Introduction to mysql part 2
 

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

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 - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
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
baabtra.com - No. 1 supplier of quality freshers
 
Php database connectivity
Php database connectivityPhp database connectivity
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 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
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Blue brain
Blue brainBlue brain
5g
5g5g
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra

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
 

Sql statements function join

  • 1.
  • 3. Disclaimer: This presentation is prepared by trainees of baabtra.com as a part of mentoring program. This is not official document of baabtra.com – Mentoring Partner
  • 4. SQL Structured Query Language SQL is Special purpose programming language designed for managing data held in Relational Data Base Management System(RDBMS)
  • 5. SQL STATEMENTS • Data Definition Language (DDL) - Define database structure/schema. • Data Manipulation Language (DML) -Manipulation on table data. Query one or more tables. • Data Control Language (DCL) -Set database permissions and privileges.
  • 6. DDL Statements are : CRAETE ALTER DROP TRUNCATE DML Statements are : INSERT SELECT UPDATE DELETE DCL Statements GRANT ROLLBACK REVOKE
  • 7. Tables in SQL PName Price Category Manufacturer Gizmo $19.99 Gadgets GizmoWorks Powergizmo $29.99 Gadgets GizmoWorks SingleTouch $149.99 Photography Canon MultiTouch $203.99 Household Hitachi Product Attribute/field/ column Table name Tuples or rows
  • 8. DDL Commands • CREATE - To create objects in data base. o CREATE DATABASE <database name>; E.g. CREATE DATABASE db_student; o CREATE TABLE tablename ( field1 datatype, field2 datatype ); E.g. CREATE TABLE tbl_student(vchr_name varchar(20),int_roll int); vchr_name int_roll NULL NULL
  • 9. • ALTER – Alter the structure of database. i.e., to add or drop columns on existing table. ALTER TABLE tablename ADD column datatype;//add column ALTER TABLE tablename DROP column; //delete a column E.g. ALTER TABLE tbl_student ADD int_mark int; //added new column mark of type integer E.g. ALTER TABLE tbl_student DROP int_mark; //deleted mark vchr_name int_roll int_mark NULL NULL NULL
  • 10. • TRUNCATE – To remove all records from table. TRUNCATE TABLE tablename; E.g. TRUNCATE TABLE tbl_student; • RENAME - to rename a table RENAME TABLE oldname TO newname’; E.g. RENAME TABLE tbl_student TO tbl_studentrecord;
  • 11. DML Commands • INSERT – Add data into the table. insert into table_name values(data1,data2,...); insert into tbl_student values(‘john’, 11); tbl_student vchr_name int_roll john 11
  • 12. • UPDATE – to update a value in a table. UPDATE table_name SET column_name=value WHERE condition. E.g. UPDATE tbl_student set vchr_name=‘james’ where chr_name=‘john’; vchr_name int_roll steve 10 james 11 vchr_name int_roll steve 10 john 11 Before update After update
  • 13. • DELETE – to delete a row from table. DELETE FROM tablename ; DELETE from tbl_student where chr_name=‘james’; pk_id vchr_name int_roll 1 steve 10 2 james 11 Before deletion After deletion pk_id vchr_name int_roll 1 steve 10
  • 14. • SELECT – Retrieve data from database. SELECT column FROM tablename; E.g1. SELECT * FROM tbl_student; //gives all columns of table pk_id vchr_name int_roll 1 steve 10 2 James 11 E.g2. SELECT pk_id,vchr_name FROM tbl_student; //gives specified columns of table pk_id vchr_name 1 steve 2 james
  • 16. Aggregate Functions Function that returns a single value, calculated from values in column. • SUM() – returns sum of column. • COUNT() – returns number of rows. • AVG() – returns average value of column. • MIN() – returns smallest value of column. • MAX() – returns largest value of column. • LAST() – returns the last value. • FIRST() – returns the first value.
  • 17. Use of aggregate functions. SELECT avg(emp_count), sum(emp_count), max(emp_count) min(emp_count), count(emp_count) from tbl_employee; brnch_num brnch_name region_num emp_count 108 New york 100 10 110 Boston 100 6 21 Chicago 200 5 404 San Diego 400 6 415 San jose 400 3 avg(emp_count) sum(emp_count) max(emp_count) min(emp_count) count(emp_count) 6 30 10 3 5
  • 18. Scalar Functions Function that returns a single value, based on input value. • UCASE() – converts a field to upper case. • LCASE() - converts a field to lower case. • LEN() – returns the length of a text filed. • ROUND() – rounds a numeric field to number of decimal specified SELECT UCASE(column_name) FROM table_name;
  • 19. JOIN OPERATION Combine rows from two or more tables, based on a common field between them. • INNER JOIN (SIMPLE JOIN OR JOIN) – Returns rows when there is a match in both tables • OUTER JOIN –Returns all the rows of both table whether it has matched or not -LEFT OUTER JOIN (LEFT JOIN) – Returns all rows from left table and matched rows from right table. - RIGHT OUTER JOIN (RIGHT JOIN)- Returns all rows from right table and matched rows from left table
  • 20. Pk_emp_id vchr_emp_name vchr_company 1 James Dell 2 John Sony 3 Albert Hp Pk_desig_id vchr_desig 1 System engineer 2 Tester 4 Tech support Tbl_emp Tbl_empdesig SELECT * FROM tbl_emp JOIN tbl_empdesig on tbl_emp.pk_emp_id=tbl_empdesig.pk_desig_id Pk_emp_id vchr_emp_name vchr_company Pk_desig_id vchr_desig 1 James Delll 1 System engineer 2 john Sony 2 Tester E.g. JOIN Common value
  • 21. LEFT OUTER JOIN Pk_emp_id vchr_emp_name Chr_company 1 James Dell 2 John Sony 3 Albert Hp Pk_desig_id vchr_desig 1 System engineer 2 Tester 4 Tech support Tbl_emp Tbl_empdesig SELECT * FROM tbl_emp LEFT JOIN tbl_empdesig on tbl_emp.pk_emp_id=tbl_empdesig.pk_desig_id Pk_emp_id vchr_emp_name vchr_company Pk_desig_id vchr_desig 1 James Delll 1 System engineer 2 john Sony 2 Tester 3 Albert Hp Null null
  • 22. RIGHT OUTER JOIN Pk_emp_id vchr_emp_name vchr_company 1 James Dell 2 John Sony 3 Albert Hp Pk_desig_id vchr_desig 1 System engineer 2 Tester 4 Tech support Tbl_emp Tbl_empdesig SELECT * FROM tbl_emp RIGHT JOIN tbl_empdesig on tbl_emp.pk_emp_id=tbl_empdesig.pk_desig_id Pk_emp_id vchr_emp_name vchr_company Pk_desig_id vchr_desig 1 James Delll 1 System engineer 2 john Sony 2 Tester null null null 4 Tech suport
  • 24. 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.
  • 25. 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
  • 26. 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