SQL Tutorial






















Data Warehousing & Business Intelligence
Area Codes Info
State Info
HTML Tutorial







































Home
SQL Commands
Table Manipulation
SQL Syntax

SQL Syntax

In this page, we list the SQL syntax for each of the SQL commands in this tutorial. For detailed explanations of each SQL syntax, please go to the individual section by clicking on the keyword.

The purpose of this page is to have a quick reference page for SQL syntax. We suggest you bookmark this page now by pressing Control-D so you can have this syntax page handy.

Select
SELECT "column_name" FROM "table_name"

Distinct
SELECT DISTINCT "column_name"
FROM "table_name"

Where
SELECT "column_name"
FROM "table_name"
WHERE "condition"

And/Or
SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"}+

In
SELECT "column_name"
FROM "table_name"
WHERE "column_name" IN ('value1', 'value2', ...)

Between
SELECT "column_name"
FROM "table_name"
WHERE "column_name" BETWEEN 'value1' AND 'value2'

Like
SELECT "column_name"
FROM "table_name"
WHERE "column_name" LIKE {PATTERN}

Order By
SELECT "column_name"
FROM "table_name"
[WHERE "condition"]
ORDER BY "column_name" [ASC, DESC]

Count
SELECT COUNT("column_name")
FROM "table_name"

Group By
SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1"

Having
SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1"
HAVING (arithematic function condition)

Create Table
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
... )

Drop Table
DROP TABLE "table_name"

Truncate Table
TRUNCATE TABLE "table_name"

Insert Into
INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)

Update
UPDATE "table_name"
SET "column_1" = [new value]
WHERE {condition}

Delete From
DELETE FROM "table_name"
WHERE {condition}



Site Map   |   Resources



1