Академический Документы
Профессиональный Документы
Культура Документы
WHERE CLAUSE = effects existing records, OPTIONAL CLAUSE, but if used with ORDER BY
must be in the right order;
WHERE CLAUSE comes 1st
o Where Clause can have multiple expressions joined by AND, OR
INSERT
THERE IS NO UNDO!!!
o UPDATE region SET regiondescription = Alaska WHERE regionid = 5
DELETE = removes records THERE IS NO UNDO!!!
o CHANT = I WILL NEVER RUN AN UPDATE OR DELETE WITHOUT A WHERE
CLAUSE
o DELETE FROM table WHERE column = value
o DELETE FROM products WHERE productid = 53
DISTINCT = eliminates duplicates
o SELECT DISTINCT column FROM table
Function = a process
o SELECT Aggregate Function (column) FROM table
o SUM summation (summarizes)
o COUNT how many records match (does not work on specific rows, must
o
o
o
o
o
use (*)
MAX maximum
MIN minimum
AVG average (takes the average between multiple items)
SELECT SUM (unitsinstock) FROM products
PER = how many students? versus How many students PER program?
GROUP BY Clause= lets us do PER activity
the only time you select a second column in an Aggregate Query is by using
GROUP BY
o Group By Foreign Key NEVER by Primary Key
o SELECT Aggregate Function (column) FROM table GROUP BY column
o SELECT AVG(column), Foreign Key FROM table GROUP BY Foreign Key
LEN
This one will add a new column that wills how the word after the @
Projection = selecting a subset of columns describing the idea that we can retrieve
only desired columns from the base table and rearrange or rename the columns in
the output view
o Choosing or eliminating a particular column
These are done in INNER JOINS (in SQL). INNER JOINS performs
either Equi or Natural depending on how the columns are named
o UNION = Merging of 2 or more tables or queries with similar column
structures
Must be compatible
MULTIPLE JOINS
SELECT columns FROM (table JOIN TYPE table ON key=key) JOIN TYPE
new table ON key FROM one of the first two original tables=new key
SQL SERVER
VARCHAR
o
varchar(5) = _ _ _ _ _
IDENTITY = auto number or auto increment
o Will make up a unique number
o Identity Increment = where it (auto number) counts by
o Identity Seed = where it (auto number) starts
o Numberic(#,#) = number of characters needed, number of characters after the
decimal
Numeric(6,2) = _ _ _ _ _ _ . _ _
Colors within SQL
o RED = string (text values)
o GREEN = comments (going to be ignored)
o Blue = key words
o Black = tables
How to add spaces
o [ ] = brackets around words in SQL Server
[Movie Titles]
o ` ` = back ticks around words - phpMyAdmin
`Move Titles`