SlideShare a Scribd company logo
SQL (Structured Query Language)
SQL Queries:
• SQL is a standard computer language for accessing and manipulating database.
• SQL statement are used to retrieve and update data in a database.
Types of Language;
There are 4 types of language
1. Data Definition Language.
2. Data Manipulation Language.
3. Transaction Control Language.
4. Data Control Language.
1. DATA DEFINITION LANGUAGE:
The Data Definition Language (DDL) permits database
Tables to be created or deleted.
• CREATE DATABASE- creates a new database table
CREAT DATABASE Cricket
CREAT A TABLE:
CREAT TABLE cricket (sarov varchar (20), six int, four int, two int, out int)
• ALTER TABLE - alters a database table
ADD COLUMN:
ALTER TABLE cricket ADD hundreds int
DROP COLUMN:
ALTER TABLE cricket DROP column hundreds
• DROP TABLE - deletes a database table
DROP cricket
2. Data Manipulation Language:
DML is used for executing queries.
• SELECT - extracts data from a database table
To select any two columns:
SELECT India, gold FROM sundar
To select all columns:
SELECT * FROM sundar
• UPDATE – It is used to modify the data in a table.
UPDATE Sundar SET name=’north’ where India=’ravi’
4Update one column in a row:
UPDATE sundar SET name =’sarov’ WHERE name=’priya’
Update several Columns in a row:
UPDATE sundar SET gold=’55’, name = ‘99’ WHERE name=’priya’
• DELETE - deletes data from a database table.
DELETE FROM sundar Where India=’abi’
Delete a Row:
DELETE FROM sundar where name=’rajesh’
Delete all Row:
DELETE FROM sundar
• INSERT INTO - inserts new data into a database table
INSET INTO sundar values (‘rajesh’,’50’,’55’,’60’,’6’)
INSERT DATA IN A SPECIFIED COLUMN:
INSERT INTO sundar (name, four) values (‘priya’, ‘20’)
To select the maximum value:
select max(two)from cricket
To Select the 2nd
maximum Value:
select max(two)from cricket where two<(select max(two) from cricket)
To Select the 5th
maximum value:
select max(six)from cricket as x where 5=(select count(distinct
six)from cricket where six>=x.six)
Select max(column2) FROM table1 AS X where N=(SELECT COUNT (DISTINCT
Column2) FROM table1 where column2>=X.column2)
To select the minimum value:
select min (six)from cricket
To Select the 2nd
minimum value:
select min(six)from cricket where SIX >(select min(six)from cricket)
JOINS:
Joins are to retrive data from two or more tables.
JOIN Refering of two tables:
Select table1.anycolumn,table2.anycolumn from table1,table2 where
table1.samecolumn=table2.samecolumn
select sarov.descripition,janika.company from sarov,janika where
sarov.descripition=janika.descripition
Inner joint
The intersection values of the two application.
Select field1.column1, field2.column2 from table1 INNER JOIN table2 ON
table1.samevalue=table2.samevalue.
Select oviya.serial, oviya1.Mgf from oviya inner join oviya1 on
oviya.company=oviya1.company
Left join:
Left join means display all the rows in table1 even there is no match in
table2.
select oviya.serial,oviya1.Mgf from oviya left join oviya1 on
oviya.company=oviya1.company
Right join:
Right join means display all the rows in table2 even there is no match in
table1.
select oviya.serial,oviya1.mgf from oviya right join oviya1 on
oviya.company=oviya1.company
Union :
(display the same name in one time)Union command is used to display
common columns in table1 & table2,when using union all column should be same
data.
Select company from oviya UNION select company from oviya1
Union ALL:
(display the same name twice)Union All is used to display all the same
column name
select company from oviya UNION ALL select company from oviya1
Order by:
Order by command is used to display in alphabetic order .
select company,model from oviya ORDER by company
Group by:
To find the sum of each and every rows(if two row’s have same name but
the amount is varies it addes that two amount values in one name and)
Select column1,sum(column2)from table1 group by column2
select company,sum(sum)from oviya2 group by sum
Having:
If the column is aggregate function we use having.
(i.e. we can also use where if it is not aggregate function)
Select column1, sum (summing column) from table1 group by column1
having Sum (summing column) condition value.
Where:
It is used to select particular value, if it is conditional.
select oviya.serial,oviya1.Num from oviya,oviya1 where
oviya.company=oviya1.company
ALIAS:
Changing the column name or table name
Column name alias:
Which is used to change the column name only
Select column1 as newcolumn1, column2 as newcolumn2 from
table1
Table name alias:
Which is used to change the table name only
Select column1, column2 from table1 AS newtable1
Between(AND):
It is used to select inbetween data’s only.
Select*from table1 where column1 between ’first name’ and ‘Last name’
Between (NOT):
Select*from table1 where coolumn1 NOT Between ‘first name’ and ‘last name’
AND:
It is used to display a row even if we give any two columns with particular row
select*from cool where SI='3'and Price='14'
OR :
It is used to display both the items with same name,it
is enough to give one command.
select*from cool where Items='mirinda' or Price='10'
SELECT *FROM table1 where column1=’value’ or column2=’value’
AND & OR:
Joins two or more conditions in a WHERE clause
Select column1,column2,column3 FROM table WHERE column1=value1 AND
column3= value2 OR column3= value2
Select country, mobile, status from food where country='India' and
Status='good' or status='bad'
OR
Select* from food where mobile='1100' or mobile='2200' and country='India'
IN:
To find the particular two details in the row is called IN
Select*from oviya2 where position in('test','j test')
Select *from table1 where column1 in (firstname, lastname)
Function:
It is the aggregate function for calculation and counting.
* Function can return value
* We can pass arguments to the function
Select function (column) from table.
Two types of Function
1. AGGREGATE FUNCTION:
Operate against the collection of values but returns single value.
2. SCALAR FUNCTION:
Operate against the collection of single values but returns single value.
STRUCTURE:
• Structure can not return value
• We can not pass any argument to the structure.
DIFFERENCE B/W HAVING & WHERE:
HAVING WHERE
HAVING is used only in Aggregate function Where is not used in the Aggregate function
SELECT INTO:
It is used to take backup from the previous table
select SI,Items,Price,Quantity into oviya5 from cool
Select column1, column2, column3 into new table from table1
TO DISPLAY ALL THE COLUMN ONCE MORE
Select column1, column2, column3, table1.* from table1
30 08 Final Sql

More Related Content

What's hot

MYSQL using set operators
MYSQL using set operatorsMYSQL using set operators
MYSQL using set operators
Ahmed Farag
 
Introduction to oracle functions
Introduction to oracle functionsIntroduction to oracle functions
Introduction to oracle functions
Nitesh Singh
 
Sql modifying data - MYSQL part I
Sql modifying data - MYSQL part ISql modifying data - MYSQL part I
Sql modifying data - MYSQL part I
Ahmed Farag
 
MYSql manage db
MYSql manage dbMYSql manage db
MYSql manage db
Ahmed Farag
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
Balqees Al.Mubarak
 
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
Raviteja Chowdary Adusumalli
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
TechandMate
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
Syed Zaid Irshad
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
RajSingh734307
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
Amrit Kaur
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle Sql
Ahmed Yaseen
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
SQL report
SQL reportSQL report
SQL report
Ahmad Zahid
 
Java class 8
Java class 8Java class 8
Java class 8Edureka!
 

What's hot (19)

MYSQL using set operators
MYSQL using set operatorsMYSQL using set operators
MYSQL using set operators
 
Introduction to oracle functions
Introduction to oracle functionsIntroduction to oracle functions
Introduction to oracle functions
 
Spufi
SpufiSpufi
Spufi
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Sql modifying data - MYSQL part I
Sql modifying data - MYSQL part ISql modifying data - MYSQL part I
Sql modifying data - MYSQL part I
 
Sql select
Sql select Sql select
Sql select
 
MYSql manage db
MYSql manage dbMYSql manage db
MYSql manage db
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
SQL
SQLSQL
SQL
 
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle Sql
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
SQL report
SQL reportSQL report
SQL report
 
Java class 8
Java class 8Java class 8
Java class 8
 

Similar to 30 08 Final Sql

Commands
CommandsCommands
Commands
Ayushi Goyal
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01sagaroceanic11
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamental
varunbhatt23
 
Database object, sub query, Join Commands & Lab Assignment
Database object, sub query, Join Commands & Lab AssignmentDatabase object, sub query, Join Commands & Lab Assignment
Database object, sub query, Join Commands & Lab Assignment
Arun Sial
 
MY SQL
MY SQLMY SQL
MY SQL
sundar
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
Pooja Dixit
 
SQL
SQLSQL
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
Swapnali Pawar
 
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
IMsKanchanaI
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdf
GaneshR321894
 
Cheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understandingCheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understanding
VivekanandaGN1
 
SQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdfSQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdf
LightWolf2
 
SQL learning notes and all code.pdf
SQL learning notes and all code.pdfSQL learning notes and all code.pdf
SQL learning notes and all code.pdf
79TarannumMulla
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
EliasPetros
 
Oraclesql
OraclesqlOraclesql
Oraclesql
Priya Goyal
 
Chapter8 my sql revision tour
Chapter8 my sql revision tourChapter8 my sql revision tour
Chapter8 my sql revision tour
KV(AFS) Utarlai, Barmer (Rajasthan)
 
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
jainendraKUMAR55
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
PADYALAMAITHILINATHA
 
SQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint PresentationSQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint Presentation
maitypradip938
 

Similar to 30 08 Final Sql (20)

Commands
CommandsCommands
Commands
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
dbms.pdf
dbms.pdfdbms.pdf
dbms.pdf
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamental
 
Database object, sub query, Join Commands & Lab Assignment
Database object, sub query, Join Commands & Lab AssignmentDatabase object, sub query, Join Commands & Lab Assignment
Database object, sub query, Join Commands & Lab Assignment
 
MY SQL
MY SQLMY SQL
MY SQL
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
SQL
SQLSQL
SQL
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
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
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdf
 
Cheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understandingCheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understanding
 
SQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdfSQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdf
 
SQL learning notes and all code.pdf
SQL learning notes and all code.pdfSQL learning notes and all code.pdf
SQL learning notes and all code.pdf
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Chapter8 my sql revision tour
Chapter8 my sql revision tourChapter8 my sql revision tour
Chapter8 my sql revision tour
 
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
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 
SQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint PresentationSQL Class Note By Amit Maity PowerPoint Presentation
SQL Class Note By Amit Maity PowerPoint Presentation
 

Recently uploaded

Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

30 08 Final Sql

  • 1. SQL (Structured Query Language) SQL Queries: • SQL is a standard computer language for accessing and manipulating database. • SQL statement are used to retrieve and update data in a database. Types of Language; There are 4 types of language 1. Data Definition Language. 2. Data Manipulation Language. 3. Transaction Control Language. 4. Data Control Language. 1. DATA DEFINITION LANGUAGE: The Data Definition Language (DDL) permits database Tables to be created or deleted. • CREATE DATABASE- creates a new database table CREAT DATABASE Cricket
  • 2. CREAT A TABLE: CREAT TABLE cricket (sarov varchar (20), six int, four int, two int, out int) • ALTER TABLE - alters a database table ADD COLUMN: ALTER TABLE cricket ADD hundreds int DROP COLUMN: ALTER TABLE cricket DROP column hundreds • DROP TABLE - deletes a database table DROP cricket 2. Data Manipulation Language: DML is used for executing queries. • SELECT - extracts data from a database table To select any two columns: SELECT India, gold FROM sundar To select all columns: SELECT * FROM sundar
  • 3. • UPDATE – It is used to modify the data in a table. UPDATE Sundar SET name=’north’ where India=’ravi’ 4Update one column in a row: UPDATE sundar SET name =’sarov’ WHERE name=’priya’ Update several Columns in a row: UPDATE sundar SET gold=’55’, name = ‘99’ WHERE name=’priya’ • DELETE - deletes data from a database table. DELETE FROM sundar Where India=’abi’ Delete a Row: DELETE FROM sundar where name=’rajesh’ Delete all Row: DELETE FROM sundar • INSERT INTO - inserts new data into a database table INSET INTO sundar values (‘rajesh’,’50’,’55’,’60’,’6’)
  • 4. INSERT DATA IN A SPECIFIED COLUMN: INSERT INTO sundar (name, four) values (‘priya’, ‘20’) To select the maximum value: select max(two)from cricket To Select the 2nd maximum Value: select max(two)from cricket where two<(select max(two) from cricket) To Select the 5th maximum value: select max(six)from cricket as x where 5=(select count(distinct six)from cricket where six>=x.six) Select max(column2) FROM table1 AS X where N=(SELECT COUNT (DISTINCT Column2) FROM table1 where column2>=X.column2) To select the minimum value: select min (six)from cricket To Select the 2nd minimum value: select min(six)from cricket where SIX >(select min(six)from cricket) JOINS: Joins are to retrive data from two or more tables. JOIN Refering of two tables: Select table1.anycolumn,table2.anycolumn from table1,table2 where table1.samecolumn=table2.samecolumn select sarov.descripition,janika.company from sarov,janika where sarov.descripition=janika.descripition
  • 5. Inner joint The intersection values of the two application. Select field1.column1, field2.column2 from table1 INNER JOIN table2 ON table1.samevalue=table2.samevalue. Select oviya.serial, oviya1.Mgf from oviya inner join oviya1 on oviya.company=oviya1.company Left join: Left join means display all the rows in table1 even there is no match in table2. select oviya.serial,oviya1.Mgf from oviya left join oviya1 on oviya.company=oviya1.company Right join: Right join means display all the rows in table2 even there is no match in table1. select oviya.serial,oviya1.mgf from oviya right join oviya1 on oviya.company=oviya1.company Union : (display the same name in one time)Union command is used to display common columns in table1 & table2,when using union all column should be same data. Select company from oviya UNION select company from oviya1
  • 6. Union ALL: (display the same name twice)Union All is used to display all the same column name select company from oviya UNION ALL select company from oviya1 Order by: Order by command is used to display in alphabetic order . select company,model from oviya ORDER by company Group by: To find the sum of each and every rows(if two row’s have same name but the amount is varies it addes that two amount values in one name and) Select column1,sum(column2)from table1 group by column2 select company,sum(sum)from oviya2 group by sum Having: If the column is aggregate function we use having. (i.e. we can also use where if it is not aggregate function) Select column1, sum (summing column) from table1 group by column1 having Sum (summing column) condition value. Where: It is used to select particular value, if it is conditional. select oviya.serial,oviya1.Num from oviya,oviya1 where oviya.company=oviya1.company ALIAS:
  • 7. Changing the column name or table name Column name alias: Which is used to change the column name only Select column1 as newcolumn1, column2 as newcolumn2 from table1 Table name alias: Which is used to change the table name only Select column1, column2 from table1 AS newtable1 Between(AND): It is used to select inbetween data’s only. Select*from table1 where column1 between ’first name’ and ‘Last name’ Between (NOT): Select*from table1 where coolumn1 NOT Between ‘first name’ and ‘last name’ AND: It is used to display a row even if we give any two columns with particular row select*from cool where SI='3'and Price='14' OR : It is used to display both the items with same name,it is enough to give one command. select*from cool where Items='mirinda' or Price='10' SELECT *FROM table1 where column1=’value’ or column2=’value’
  • 8. AND & OR: Joins two or more conditions in a WHERE clause Select column1,column2,column3 FROM table WHERE column1=value1 AND column3= value2 OR column3= value2 Select country, mobile, status from food where country='India' and Status='good' or status='bad' OR Select* from food where mobile='1100' or mobile='2200' and country='India' IN: To find the particular two details in the row is called IN Select*from oviya2 where position in('test','j test') Select *from table1 where column1 in (firstname, lastname) Function: It is the aggregate function for calculation and counting. * Function can return value * We can pass arguments to the function Select function (column) from table. Two types of Function 1. AGGREGATE FUNCTION: Operate against the collection of values but returns single value. 2. SCALAR FUNCTION: Operate against the collection of single values but returns single value.
  • 9. STRUCTURE: • Structure can not return value • We can not pass any argument to the structure. DIFFERENCE B/W HAVING & WHERE: HAVING WHERE HAVING is used only in Aggregate function Where is not used in the Aggregate function SELECT INTO: It is used to take backup from the previous table select SI,Items,Price,Quantity into oviya5 from cool Select column1, column2, column3 into new table from table1 TO DISPLAY ALL THE COLUMN ONCE MORE Select column1, column2, column3, table1.* from table1