Nimakarimian Sql-Cheatsheet - BW
Nimakarimian Sql-Cheatsheet - BW
cheatography.com/nimakarimian/
www.nimakarimian.ir
SQL CheatSheet Cheat Sheet
by Nima (nimakarimian) via cheatography.com/113429/cs/33110/
cheatography.com/nimakarimian/
www.nimakarimian.ir
SQL CheatSheet Cheat Sheet
by Nima (nimakarimian) via cheatography.com/113429/cs/33110/
Altern [] Represents
SELECT ProductName, UnitPrice * (UnitsInStock + COALESCE(UnitsOnOrder, 0))any singleProdh[oa]t finds
FROM
ative ucts; SELECT column_name(s) FROM character within the hot and hat,
table1 brackets but not hit
COALESCE() Function Works with MYSQL
SQLSERVER and ORACLE UNION ^ Represents any h[^oa]t finds
SELECT column_name(s) FROM character not in the hit, but not
ANY & ALL table2; brackets hot and hat
The UNION operator selects only - Represents any single c[a-b]t finds
ANY SELECT column_name(s) FROM table_name WHERE column_name operator ANY (SELECT column_name FROM table
distinct values by default. character within the cat and cbt
on);
To allow duplicate values, use specified range
ALL SELECT column_name(s) FROM table_name WHERE column_name operator ALL (SELECT column_name FROM table
UNION ALL:
on); MIN() & MAX()
SELECT column_name(s) FROM
SOME SELECT * FROM Products WHERE Price > SOME (SELECT Price FROM Products WHERE Price > 20);
table1 MIN() SELECT MIN(column_name) FROM ta
returns a boolean value as a result UNION n;
The operator must be a standard SELECT column_name(s) FROM
MAX() SELECT MAX(column_name) FROM ta
comparison operator (=, <>, !=, >, >=, <, or table2;
n;
<=).
The UNION operator is used to combine the
**you can use MIN() and MAX() anywhere
result-set of two or more SELECT statem‐
WHERE keyword in any Query you like
ents.
the examples above are just to show
SELECT Col1,Col2 FROM tablename
implementation**
WHERE condition Every SELECT statement within UNION
must have the same number of columns
WHERE is for when you want to declare a DELETE
The columns must also have similar data
specific condition for the query. in the other DELETE DELETE FROM table_name;
types
hand, you want to filter the records EVERYTHING
The columns in every SELECT statement
TIP1 WHERE can be used in UPDATE,
must also be in the same order DELETE DELETE FROM table_name WHER
SELECT, DELETE, ETC...
WITH
Aliases CONDITION
WILDCARDS
cheatography.com/nimakarimian/
www.nimakarimian.ir
SQL CheatSheet Cheat Sheet
by Nima (nimakarimian) via cheatography.com/113429/cs/33110/
cheatography.com/nimakarimian/
www.nimakarimian.ir
SQL CheatSheet Cheat Sheet
by Nima (nimakarimian) via cheatography.com/113429/cs/33110/
cheatography.com/nimakarimian/
www.nimakarimian.ir
SQL CheatSheet Cheat Sheet
by Nima (nimakarimian) via cheatography.com/113429/cs/33110/
CREATE INDEX
CREATE TABLE new_table_name AS SELECT column1, column2,...
from ....; CREATE CREATE INDEX index_name ON tabl
another
CREATE CREATE UNIQUE INDEX index_name
Table
UNIQUE
DROP - DROP INDEX table_name.index
SQLSE‐
RVER-
DROP - ALTER TABLE table_name DROP IND
MYSQL-
DROP - DROP INDEX index_name;
ORACLE-
cheatography.com/nimakarimian/
www.nimakarimian.ir
SQL CheatSheet Cheat Sheet
by Nima (nimakarimian) via cheatography.com/113429/cs/33110/
cheatography.com/nimakarimian/
www.nimakarimian.ir