SQL II

Review Time

*

Select Everything

Review Time

ORDER BY

Choose column which you would like your data ordered by. Has option ASCending or DESCending value.

Review Time

LIMIT

Limit the amount of data you get back from your query.

Review Time

SUM()

Finds the sum of the data. Access it like this: sum(COLUMN_NAME)

Review Time

COUNT()

Finds the count, or total number of items, of the data we query for. Access it like this: count(COLUMN_NAME)

Review Time

AVG()

Finds the average of the data we query for. Access it like this: avg(COLUMN_NAME). Remember average is the total amount divided by the total count

Review Time

MAX()

Finds the max of the data we query for. Access it like this: max(COLUMN_NAME). Returns only one piece of data.

Review Time

MIN()

Finds the minimum of the data we query for. Access it like this: min(COLUMN_NAME).

Returns only one piece of data.

Review Time

LIKE

Underscore to place for single letter

 

WHERE name LIKE '_onathan'

Percent to match any number of letters before or after depending on placement.

 

WHERE name LIKE 'J%'

Review Time

Select Empty Data

SELECT * FROM users

WHERE name IS NULL;

SELECT * FROM users

WHERE name IS NOT NULL

Review Time

Add Rows

INSERT INTO users (

  first_name,

  last_name,

  email

) VALUES (

  'Bryan',

  'Smith',

  'bryan@devmountain.com'

);

Review Time

Delete Rows

DELETE FROM users

WHERE name = 'Bryan';

Be careful with this one. It is always a good practice to do a select first to see what data you will be deleting.

Review Time

Update Rows

UPDATE users

SET name = 'Jase'

WHERE user_id = 4;

Be careful with this one. It is always a good practice to do a select first to see what data you will be updating.

Review Time

DISTINCT

SELECT DISTINCT name FROM users;

Find the unique values. No duplicates.

Normalization

As your application grows, you will find a need for multiple tables. Each table will have data that another table may find useful. The process of splitting out our data into multiple tables is called normalization.

Please don't pile all of your data into one table. This would be like stuffing all of your clothes into one dresser drawer. You want a swimsuit? Too bad, here is that shirt you've had since 8th grade

SQL II

By awestenskow

SQL II

  • 118