The purpose of this post is to have a quick reference for SQL syntax.
Select Statement
Distinct
Where
And/Or
In
Between
Like
Order By
Count
Group By
Having
Create Table Statement
Drop Table Statement
Truncate Table Statement
Insert Into Statement
Update Statement
Delete From Statement
Select Statement
SELECT "column_name"
FROM "table_name";
FROM "table_name";
Distinct
SELECT DISTINCT "column_name"
FROM "table_name";
FROM "table_name";
Where
SELECT "column_name"
FROM "table_name"
WHERE "condition";
FROM "table_name"
WHERE "condition";
And/Or
SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"};
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"};
In
SELECT "column_name" FROM "table_name"
WHERE "column_name" IN ('value1', 'value2', ...);
WHERE "column_name" IN ('value1', 'value2', ...);
Between
SELECT "column_name"
FROM "table_name"
WHERE "column_name" BETWEEN 'value1' AND 'value2';
FROM "table_name"
WHERE "column_name" BETWEEN 'value1' AND 'value2';
Like
SELECT "column_name"
FROM "table_name"
WHERE "column_name" LIKE {PATTERN};
FROM "table_name"
WHERE "column_name" LIKE {PATTERN};
Order By
SELECT "column_name"
FROM "table_name"
[WHERE "condition"]
ORDER BY "column_name" [ASC, DESC];
FROM "table_name"
[WHERE "condition"]
ORDER BY "column_name" [ASC, DESC];
Count
SELECT COUNT("column_name")
FROM "table_name";
FROM "table_name";
Group By
SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1";
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);
FROM "table_name"
GROUP BY "column_name1"
HAVING (arithematic function condition);
Create Table Statement
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",... );
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",... );
Drop Table Statement
DROP TABLE "table_name";
Truncate Table Statement
TRUNCATE TABLE "table_name";
Insert Into Statement
INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...);
VALUES ("value1", "value2", ...);
Update Statement
UPDATE "table_name"
SET "column_1" = [new value]
WHERE {condition};
SET "column_1" = [new value]
WHERE {condition};
Delete From Statement
DELETE FROM "table_name"
WHERE {condition};
WHERE {condition};
i would be better if u provide etl specs
ReplyDelete
ReplyDeleteGreat Article
Artificial Intelligence Projects
machine learning final year projects 2020
JavaScript Training in Chennai
JavaScript Training in Chennai Project Centers in Chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai