SQL - Syntax pt.2 Flashcards
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name;
SQL SELECT Statement
SELECT
column1, column2….columnN FROM table_name;
Various Syntax in SQL
SELECT DISTINCT column1, column2….columnN
FROM table_name;
SQL DISTINCT Clause
SELECT DISTINCT
column1, column2….columnN
FROM table_name;
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name
WHERE CONDITION;
SQL WHERE Clause
SELECT column1, column2….columnN
FROM table_nameWHERE
CONDITION;
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name
WHERE CONDITION-1 {AND|OR} CONDITION-2;
SQL AND/OR Clause
WHERE CONDITION-1 {AND|OR
} CONDITION-2;
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name
WHERE column_name IN (val-1, val-2,…val-N);
SQL IN Clause
WHERE column_name IN
(val-1, val-2,…val-N);
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name
WHERE column_name BETWEEN val-1 AND val-2;
SQL BETWEEN Clause
WHERE column_name BETWEEN
val-1 AND val-2;
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name
WHERE column_name LIKE { PATTERN };
SQL LIKE Clause
WHERE column_name LIKE
{ PATTERN };
Various Syntax in SQL
SELECT column1, column2….columnN
FROM table_name
WHERE CONDITION
ORDER BY column_name {ASC|DESC};
SQL ORDER BY Clause
ORDER BY
column_name {ASC|DESC
};
Various Syntax in SQL
SELECT SUM(column_name)
FROM table_name
WHERE CONDITION
GROUP BY column_name;
SQL GROUP BY Clause
GROUP BY
column_name;
Various Syntax in SQL
SELECT COUNT(column_name)
FROM table_name
WHERE CONDITION;
SQL COUNT Clause
SELECT COUNT
(column_name)
FROM table_name
WHERE CONDITION;
Various Syntax in SQL
SELECT SUM(column_name)
FROM table_name
WHERE CONDITION
GROUP BY column_name
HAVING (arithematic function condition);
SQL HAVING Clause
HAVING
(arithematic function condition);
Various Syntax in SQL
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
…..
columnN datatype,
PRIMARY KEY( one or more columns )
);
SQL CREATE TABLE Statement
CREATE TABLE
table_name(
column1 datatype,
Various Syntax in SQL
DROP TABLE table_name;
SQL DROP TABLE Statement
DROP TABLE
table_name;
Various Syntax in SQL
CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,…columnN);
SQL CREATE INDEX Statement
CREATE
UNIQUE INDEX
index_name
ON table_name ( column1, column2,…)
Various Syntax in SQL
ALTER TABLE table_name
DROP INDEX index_name;
SQL DROP INDEX Statement
ALTER TABLE table_nameDROP INDEX
index_name;