เป็นคำสั่งที่ใช้สำหรับการเรียกดูข้อมูลในตาราง (Table)
คำสั่ง SQL SELECT สามารถเรียกได้ทั้งตาราง
หรือว่า สามารถระบุฟิวด์ที่ต้องการเรียกดูข้อมูลได้
Database : MySQL,Microsoft Access,SQL Server,OracleSyntax
SELECT Column1, Column2, Column3,...
FROM [Table-Name]
Table
: customer
CustomerID
|
Name
|
Email
|
CountryCode
|
Budget
|
Used
|
C001
|
Win Weerachai
|
win.weerachai@thaicreate.com
|
TH
|
1000000
|
600000
|
C002
|
John Smith
|
john.smith@thaicreate.com
|
EN
|
2000000
|
800000
|
C003
|
Jame Born
|
jame.born@thaicreate.com
|
US
|
3000000
|
600000
|
C004
|
Chalee Angel
|
chalee.angel@thaicreate.com
|
US
|
4000000
|
100000
|
Sample1 การเลือกข้อมูลที่ระบุฟิวด์
SELECT CustomerID, Name, Email FROM
customer
Output
CustomerID
|
Name
|
Email
|
C001
|
Win Weerachai
|
win.weerachai@thaicreate.com
|
C002
|
John Smith
|
john.smith@thaicreate.com
|
C003
|
Jame Born
|
jame.born@thaicreate.com
|
C004
|
Chalee Angel
|
chalee.angel@thaicreate.com
|
Sample2 การเลือกข้อมูลทั้งหมดของ Table
SELECT * FROM customer
Output
CustomerID
|
Name
|
Email
|
CountryCode
|
Budget
|
Used
|
C001
|
Win Weerachai
|
win.weerachai@thaicreate.com
|
TH
|
1000000
|
600000
|
C002
|
John Smith
|
john.smith@thaicreate.com
|
EN
|
2000000
|
800000
|
C003
|
Jame Born
|
jame.smith@thaicreate.com
|
US
|
3000000
|
600000
|
C004
|
Chalee Angel
|
chalee.angel@thaicreate.com
|
US
|
4000000
|
100000
|
ที่มา : http://www.thaicreate.com/tutorial/sql-select.html
ไม่มีความคิดเห็น:
แสดงความคิดเห็น