0% found this document useful (0 votes)
37 views2 pages

Select Statement

This document describes SQL statements for selecting, filtering, grouping, aggregating, and modifying data in database tables. It covers basic statements like SELECT, WHERE, and ORDER BY as well as more advanced statements like GROUP BY, HAVING, CREATE TABLE, INSERT, UPDATE, and DELETE. The document provides the basic syntax for each statement and examples of how to use them to query and manage data in database tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Select Statement

This document describes SQL statements for selecting, filtering, grouping, aggregating, and modifying data in database tables. It covers basic statements like SELECT, WHERE, and ORDER BY as well as more advanced statements like GROUP BY, HAVING, CREATE TABLE, INSERT, UPDATE, and DELETE. The document provides the basic syntax for each statement and examples of how to use them to query and manage data in database tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Select Statement

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", [Function("column_name2")]
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 1 constraint(s)],
"column 2" "data type for column 2" [column 2 constraint(s)],
...
[table constraint(s)]);

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", ...);

Insert Into Select Statement


INSERT INTO "table1" ("column1", "column2", ...)
SELECT "column3", "column4", ...
FROM "table2";

Update Statement
UPDATE "table_name"
SET "column_1" = [new value]
WHERE "condition";

Delete From Statement


DELETE FROM "table_name"
WHERE "condition";

You might also like