SQL CHEAT SHEET
Note: SELECT queries are the only queries that I will expect you to memorize. The others I will only expect you to understand.
Select Query
SELECT <fields> AS <alias>
FROM <tables>
WHERE
<join rules> AND
<criteria rules>
ORDER BY <field> [ASC/DESC]
Example:
select AuthorName AS Author, BookName AS Title
from BookTable, AuthorTable
where BookTable.AuthorID = AuthorTable.AuthorID AND
BookTable.PublishedDate < 1976
order by AuthorTable.AuthorName
Update Query
UPDATE <table>
SET <field> = <value>
WHERE <criteria>
Example:
update CountryTable
set CountryName = ¡°Samoa¡±
where CountryName like ¡°Western Samoa¡±
Delete Query
DELETE <field>
FROM <table>
WHERE <criteria>
Exmaple:
delete TakesClassTable.*
from TakesClassTable, StudentTable
where
TakesClassTable.StudentID = StudentTable.StudentID AND
StudentTable.PaidTuition = false
Insert Query
INSERT INTO <table> (<fields>)
VALUES (<values>)
Example:
insert into ClassTable (ClassID, ClassName, ClassTime)
values (45, ¡°CSB184¡±, ¡°TTh1-3¡±)