SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
K.Warawut SQL Overview 1
SQL OverviewSQL Overview
Suan Dusit Rajabhat University Phitsanulok CampusSuan Dusit Rajabhat University Phitsanulok Campus
Mr.Warawut KhangkhanMr.Warawut Khangkhan
K.Warawut SQL Overview 2
กลมค สงกลมค สง SQLSQL
●
ค สงนย มขอมล (Data Definition Language:
DDL)
●
ค สงด เนนก รขอมล (Data Manipulation
Language: DML)
●
ค สงควบคมขอมล (Data Control Language:
DCL)
K.Warawut SQL Overview 3
ค สงด เนนก รกบขอมลค สงด เนนก รกบขอมล
(Data Manipulation Language: DML)(Data Manipulation Language: DML)
●
เปนกลมค สงทใชด เนนก รกบขอมลในฐ นขอมล
เชน ก รเพม ลบ ปรบปรง และเรยกดขอมล เปนตน
●
ค สงในกลมน%จะไมส ม รถเปลยนแปลง
โครงสร งของฐ นขอมลได
K.Warawut SQL Overview 4
ก รเพมขอมลในก รเพมขอมลใน TableTable
รปแบบ
INSERT INTO table-name [(col-1, ..., col-n)]
VALUES (value-1, ..., value-n);
K.Warawut SQL Overview 5
ก รแกไขขอมลในก รแกไขขอมลใน TableTable
รปแบบ
UPDATE table-name
SET col-1 = value-1, ..., col-n = value-n
[WHERE condition];
K.Warawut SQL Overview 6
ก รลบขอมลในก รลบขอมลใน TableTable
รปแบบ
DELETE FROM table-name
[WHERE condition];
K.Warawut SQL Overview 7
ก รเรยกดขอมลในก รเรยกดขอมลใน TableTable
รปแบบ
SELECT * | [DISTINCT] col-1, col-2, ..., col-n
FROM table-name
[WHERE condition]
[GROUP BY col-1, col-2, ..., col-n]
[HAVING condition]
[ORDER BY col-1, col-2, ..., col-n];
K.Warawut SQL Overview 8
ก รเรยกดขอมลม กกวก รเรยกดขอมลม กกว 1 Table1 Table
●
ตองมก รรวมขอมลจ กหล ยต ร งดวยก รใชค สง
JOIN
– Inner Join ไดแก Equijoin, Non-Equijoin, Cross
Join และ Self Join
– Outer Join ไดแก Left Outer Join, Right Outer
Join และ Full Outer Join
K.Warawut SQL Overview 9
EquijoinEquijoin
●
เปนก รจบคแถวทมขอมลตรงกนของ 2 ต ร ง ค+อ
มลกษณะเปนก รใชเคร+องหม ยเท กบ (=) ในก ร
จบค
●
รปแบบ
table-name1 INNER JOIN table-name2 ON
table-name1.col1 = table-name2.col2
K.Warawut SQL Overview 10
Example EquijoinExample Equijoin
SELECT Sales.SalesID, SFirstName, SLastName
FORM Sales INNER JOIN Orders
ON Sales.SalesID = Orders.SalesID
WHERE Orders.OrderDate = '2549-10-21';
K.Warawut SQL Overview 11
Contact usContact us
Mr.Warawut KhangkhanMr.Warawut Khangkhan
Social Media:
http://www.facebook.com/awarawut
http://twitter.com/awarawut
Web Site:
http://awarawut.blogspot.com
E-Mail:
awarawut@hotmail.com
Mobile:
083-0698-410

Contenu connexe

En vedette

En vedette (14)

Equipo 9 plan nacional de desarrollo
Equipo 9 plan nacional de desarrolloEquipo 9 plan nacional de desarrollo
Equipo 9 plan nacional de desarrollo
 
Prática curricular iv conversa preliminar - cópia
Prática curricular iv   conversa preliminar - cópiaPrática curricular iv   conversa preliminar - cópia
Prática curricular iv conversa preliminar - cópia
 
11. història art segle xix
11. història art segle xix11. història art segle xix
11. història art segle xix
 
The Journey To Allah
The Journey To AllahThe Journey To Allah
The Journey To Allah
 
中国社交游戏年度报告 Cecilia
中国社交游戏年度报告 Cecilia中国社交游戏年度报告 Cecilia
中国社交游戏年度报告 Cecilia
 
Psychological risks of videogame usage by Florian Rehbein
Psychological risks of videogame usage by Florian RehbeinPsychological risks of videogame usage by Florian Rehbein
Psychological risks of videogame usage by Florian Rehbein
 
Amazônia uma historia de perdas e danos um futuro a re construir
Amazônia uma historia de perdas e danos  um futuro a  re  construirAmazônia uma historia de perdas e danos  um futuro a  re  construir
Amazônia uma historia de perdas e danos um futuro a re construir
 
Computación
ComputaciónComputación
Computación
 
Alertanuevadroga
AlertanuevadrogaAlertanuevadroga
Alertanuevadroga
 
Premonsoonchitawan
PremonsoonchitawanPremonsoonchitawan
Premonsoonchitawan
 
Fósiles en león
Fósiles en leónFósiles en león
Fósiles en león
 
Codigo civil-para-el-estado-libre-y-soberano-de-puebla
Codigo civil-para-el-estado-libre-y-soberano-de-pueblaCodigo civil-para-el-estado-libre-y-soberano-de-puebla
Codigo civil-para-el-estado-libre-y-soberano-de-puebla
 
Fotógrafos
FotógrafosFotógrafos
Fotógrafos
 
Practica nº7
Practica nº7Practica nº7
Practica nº7
 

Plus de Warawut

Object-Oriented Programming 7
Object-Oriented Programming 7Object-Oriented Programming 7
Object-Oriented Programming 7
Warawut
 
Object-Oriented Programming 6
Object-Oriented Programming 6Object-Oriented Programming 6
Object-Oriented Programming 6
Warawut
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1
Warawut
 

Plus de Warawut (20)

Database design
Database designDatabase design
Database design
 
Business Computer Project 4
Business Computer Project 4Business Computer Project 4
Business Computer Project 4
 
Object-Oriented Programming 10
Object-Oriented Programming 10Object-Oriented Programming 10
Object-Oriented Programming 10
 
Object-Oriented Programming 9
Object-Oriented Programming 9Object-Oriented Programming 9
Object-Oriented Programming 9
 
Object-Oriented Programming 8
Object-Oriented Programming 8Object-Oriented Programming 8
Object-Oriented Programming 8
 
Object-Oriented Programming 7
Object-Oriented Programming 7Object-Oriented Programming 7
Object-Oriented Programming 7
 
Object-Oriented Programming 6
Object-Oriented Programming 6Object-Oriented Programming 6
Object-Oriented Programming 6
 
Management Information System 6
Management Information System 6Management Information System 6
Management Information System 6
 
Management Information System 5
Management Information System 5Management Information System 5
Management Information System 5
 
Management Information System 4
Management Information System 4Management Information System 4
Management Information System 4
 
Object-Oriented Programming 5
Object-Oriented Programming 5Object-Oriented Programming 5
Object-Oriented Programming 5
 
Business Computer Project 3
Business Computer Project 3Business Computer Project 3
Business Computer Project 3
 
Management Information System 3
Management Information System 3Management Information System 3
Management Information System 3
 
Chapter 2 Strategy & Information System
Chapter 2 Strategy & Information SystemChapter 2 Strategy & Information System
Chapter 2 Strategy & Information System
 
Object-Oriented Programming 4
Object-Oriented Programming 4Object-Oriented Programming 4
Object-Oriented Programming 4
 
Business Computer Project 1
Business Computer Project 1Business Computer Project 1
Business Computer Project 1
 
Chapter 1 Organization & MIS
Chapter 1 Organization & MISChapter 1 Organization & MIS
Chapter 1 Organization & MIS
 
Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1
 

01 sql-overview

  • 1. K.Warawut SQL Overview 1 SQL OverviewSQL Overview Suan Dusit Rajabhat University Phitsanulok CampusSuan Dusit Rajabhat University Phitsanulok Campus Mr.Warawut KhangkhanMr.Warawut Khangkhan
  • 2. K.Warawut SQL Overview 2 กลมค สงกลมค สง SQLSQL ● ค สงนย มขอมล (Data Definition Language: DDL) ● ค สงด เนนก รขอมล (Data Manipulation Language: DML) ● ค สงควบคมขอมล (Data Control Language: DCL)
  • 3. K.Warawut SQL Overview 3 ค สงด เนนก รกบขอมลค สงด เนนก รกบขอมล (Data Manipulation Language: DML)(Data Manipulation Language: DML) ● เปนกลมค สงทใชด เนนก รกบขอมลในฐ นขอมล เชน ก รเพม ลบ ปรบปรง และเรยกดขอมล เปนตน ● ค สงในกลมน%จะไมส ม รถเปลยนแปลง โครงสร งของฐ นขอมลได
  • 4. K.Warawut SQL Overview 4 ก รเพมขอมลในก รเพมขอมลใน TableTable รปแบบ INSERT INTO table-name [(col-1, ..., col-n)] VALUES (value-1, ..., value-n);
  • 5. K.Warawut SQL Overview 5 ก รแกไขขอมลในก รแกไขขอมลใน TableTable รปแบบ UPDATE table-name SET col-1 = value-1, ..., col-n = value-n [WHERE condition];
  • 6. K.Warawut SQL Overview 6 ก รลบขอมลในก รลบขอมลใน TableTable รปแบบ DELETE FROM table-name [WHERE condition];
  • 7. K.Warawut SQL Overview 7 ก รเรยกดขอมลในก รเรยกดขอมลใน TableTable รปแบบ SELECT * | [DISTINCT] col-1, col-2, ..., col-n FROM table-name [WHERE condition] [GROUP BY col-1, col-2, ..., col-n] [HAVING condition] [ORDER BY col-1, col-2, ..., col-n];
  • 8. K.Warawut SQL Overview 8 ก รเรยกดขอมลม กกวก รเรยกดขอมลม กกว 1 Table1 Table ● ตองมก รรวมขอมลจ กหล ยต ร งดวยก รใชค สง JOIN – Inner Join ไดแก Equijoin, Non-Equijoin, Cross Join และ Self Join – Outer Join ไดแก Left Outer Join, Right Outer Join และ Full Outer Join
  • 9. K.Warawut SQL Overview 9 EquijoinEquijoin ● เปนก รจบคแถวทมขอมลตรงกนของ 2 ต ร ง ค+อ มลกษณะเปนก รใชเคร+องหม ยเท กบ (=) ในก ร จบค ● รปแบบ table-name1 INNER JOIN table-name2 ON table-name1.col1 = table-name2.col2
  • 10. K.Warawut SQL Overview 10 Example EquijoinExample Equijoin SELECT Sales.SalesID, SFirstName, SLastName FORM Sales INNER JOIN Orders ON Sales.SalesID = Orders.SalesID WHERE Orders.OrderDate = '2549-10-21';
  • 11. K.Warawut SQL Overview 11 Contact usContact us Mr.Warawut KhangkhanMr.Warawut Khangkhan Social Media: http://www.facebook.com/awarawut http://twitter.com/awarawut Web Site: http://awarawut.blogspot.com E-Mail: awarawut@hotmail.com Mobile: 083-0698-410