SELECT
SELECT "欄位" FROM "表格名稱";
WHERE
SELECT "欄位"
FROM "表格名稱"
WHERE "條件式"
條件式為:欄位=值
DISTINCT
SELECT DISTINCT "欄位"
FROM "表格名稱"
COUNT
SELECT COUNT("欄位")
FROM "表格名稱"
ORDER BY
SELECT "欄位"
FROM "表格名稱"
WHERE "條件" #[不一定要有]
ORDER BY "欄位" [ASC|DESC] #[要放在最後]
GROUP BY
SELECT "欄位1", SUM("欄位2")
FROM "表格名稱"
GROUP BY "欄位1"
HAVING
SELECT "欄位1", SUM("欄位2")
FROM "表格名稱"
GROUP BY "欄位1"
HAVING (函數條件)
CREATE TABLE
CREATE TABLE "表格名稱"
("欄位 1" "資料種類",
"欄位 2" "資料種類"",
... )"基本設定";
DROP TABLE
DROP TABLE "表格名稱"
TRUNCATE TABLE
TRUNCATE TABLE "表格名稱"
INSERT INTO
INSERT INTO "表格名稱" ("欄位1", "欄位2", ...)
VALUES ("值1", "值2", ...)
UPDATE
UPDATE "表格名稱"
SET "欄位1" = 要更新的值
WHERE "條件式"
DELETE FROM
DELETE FROM "表格名稱"
WHERE "條件式"
AND及OR
SELECT "欄位"
FROM "表格名稱"
WHERE "條件式"
AND "條件式"
OR "條件式"
IN
SELECT "欄位"
FROM "表格名稱"
WHERE "欄位" IN ('值1','值2','值3',...)
BETWEEN
SELECT "欄位"
FROM "表格名稱"
WHERE "欄位" BETWEEN '值1' AND '值2'
LIKE
SELECT "欄位"
FROM "表格名稱"
WHERE "欄位" LIKE 值
IF("條件式",真,假)
SELECT "欄位"
FROM "表格名稱"
WHERE 欄位=IF("條件式",真,假)
CASE
WHEN "條件式"
THEN "條件為成立"
ELSE "條件為不成立"
END
SELECT
CASE
WHEN "欄位"="值"
THEN 1
ELSE 0
END
FROM "表格名稱"
其它文章
- 首頁
- JAVA 目錄
- JAVA WEB 目錄
- JAVA 其他未分類 目錄
- Grails目錄
- jQuery 目錄
- Apache 目錄
- JavaScript 目錄
- Spring + Hibernate 目錄
- Hibernate 目錄
- Linux 目錄
- 程式開發工具目錄
- MySQL 目錄
- PHP目錄
- C/C++ 目錄
- Google App Engine 目錄
- HTML5/CSS3
- 程式開發基本資訊
- Android
- Oracle 目錄
- Struts 目錄
留言列表