* Select Statement
SELECT “column_name” FROM “table_name”<hr>

* Distinct
SELECT DISTINCT “column_name”
FROM “table_name”<hr>
* Where
SELECT “column_name”
FROM “table_name”
WHERE “condition”<hr>
* And/Or
SELECT “column_name”
FROM “table_name”
WHERE “simple condition”
{[AND|OR] “simple condition”}+<hr>
* In
SELECT “column_name”
FROM “table_name”
WHERE “column_name” IN (‘value1′, ‘value2′, …)<hr>
* Between
SELECT “column_name”
FROM “table_name”
WHERE “column_name” BETWEEN ‘value1′ AND ‘value2′<hr>
* Like
SELECT “column_name”
FROM “table_name”
WHERE “column_name” LIKE {PATTERN}<hr>
* Order By
SELECT “column_name”
FROM “table_name”
[WHERE “condition”]
ORDER BY “column_name” [ASC, DESC]<hr>
* Count
SELECT COUNT(“column_name”)
FROM “table_name”<hr>
* Group By
SELECT “column_name1″, SUM(“column_name2″)
FROM “table_name”
GROUP BY “column_name1″<hr>
* Having
SELECT “column_name1″, SUM(“column_name2″)
FROM “table_name”
GROUP BY “column_name1″
HAVING (arithematic function condition)<hr>
* Create Table Statement
CREATE TABLE “table_name”
(“column 1″ “data_type_for_column_1″,
“column 2″ “data_type_for_column_2″,
… )<hr>
* Drop Table Statement
DROP TABLE “table_name”<hr>
* Truncate Table Statement
TRUNCATE TABLE “table_name”<hr>
* Insert Into Statement
INSERT INTO “table_name” (“column1″, “column2″, …)
VALUES (“value1″, “value2″, …)<hr>
* Update Statement
UPDATE “table_name”
SET “column_1″ = [new value]
WHERE {condition}<hr>
* Delete From Statement
DELETE FROM “table_name”
WHERE {condition}

About these ads