ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
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
¨C Inner Join ???? Equijoin, Non-Equijoin, Cross
Join ??? Self Join
¨C 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

More Related Content

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 ¨C Inner Join ???? Equijoin, Non-Equijoin, Cross Join ??? Self Join ¨C 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