SQL資料庫語言
基本概念
SQL (Structured Query Language)定義與維護關連式資料庫的標準語言
SQL 的普及性
前端:Microsoft Access與Foxpro資料庫應用軟體,Microsoft Visual Basic / Microsoft Access Jet database engine 等ODBC資料庫存取介面
現今市面上所有關聯性資料庫軟體幾乎都支援SQL。
後端:Microsoft SQL server,mySQL,Oracle
SQL in Microsoft Access
* 『查詢 (Query)』之『SQL 檢視』 (圖形化設計自動轉換為SQL敘述)
* 『巨集 (Macro)』之『巨集指令』 - RunSQL
SQL語法
連結外站:SQL語法教學
SQL 敘述─SELECT
語法: SELECT {field list}
FROM {table}
WHERE {criteria}
ORDER BY {order field list}
範例: SELECT [StuID], [Cname], [Sex]
FROM [USTD83A]
WHERE [Dep]= "332" and [Grade]="2"
ORDER BY [StuID]
SQL 敘述─無重複記錄SELECT
語法: SELECT DISTINCT {field list}
FROM {table}
WHERE {criteria}
ORDER BY {order field list}
範例: SELECT DISTINCT [Crsno]
FROM [UCHC83A]
WHERE [StuID] LIKE "8232*"
ORDER BY [Crsno]
SQL 敘述─關聯性SELECT
語法: SELECT {field list}
FROM {table1} INNER JOIN {table2}
ON {table1.field} = {table2 .field}
WHERE {criteria}
範例: SELECT UCHC83A.StuID, USTD83A.Cname
FROM UCHC83A INNER JOIN USTD83A
ON UCHC83A.StuID= USTD83A.StuID
WHERE UCHC83A.Crsno = "1589"
SQL 敘述─DELETE
語法: DELETE FROM {table}
WHERE {criteria}
範例: DELETE FROM [USTD83A]
WHERE [Grade] = 4
SQL 敘述─UPDATE
語法: UPDATE {table}
SET {field} = new value
WHERE {criteria}
範例: UPDATE [USTD83A]
SET [Grade] = [Grade] + 1
WHERE [Grade] 4
SQL 集成函數--Avg, Count, First, Last, Max, Min, StDev, Sum, Var...
語法: SELECT function(field) AS var
FROM {table}
WHERE {criteria}
範例: SELECT Count(StuID) AS StudCount
FROM [UCHC83A]
WHERE Crsno = "1589"
SQL與後端資料庫連結