close

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 "表格名稱"




 















其它文章

 

arrow
arrow
    創作者介紹
    創作者 PG Levin Li 的頭像
    PG Levin Li

    程式開發學習之路

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()