Skip to content

Instantly share code, notes, and snippets.

@simonhlee97
Last active September 4, 2017 02:39
Show Gist options
  • Save simonhlee97/43066f70a51367ac7828a8d221ea0740 to your computer and use it in GitHub Desktop.
Save simonhlee97/43066f70a51367ac7828a8d221ea0740 to your computer and use it in GitHub Desktop.

Try SQL course (from codeschool.com)

SELECT title
FROM movies
WHERE id = 2;

SELECT * FROM movies
WHERE title = 'The Kid';

to sort data - ORDER BY...

SELECT title
FROM movies
ORDER BY duration ASC;

retrieve all films > 100 minutes:
SELECT * FROM movies WHERE duration > 100;

(<> is the Not Equal comparison operator)

AND operator: to filter multiple conditions...
SELECT ___
FROM ____
WHERE _____
AND ___;

  1. Adding Data
    INSERT INTO tablename (column)
    VALUES (data);

INSERT INTO movies (id, title, genre, duration)
VALUES (5, 'The Circus', 'Comedy', 71);

Updating data:
UPDATE _ _ _
SET _ _ _ = _ _ _
(WHERE clause)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment