Skip to content

Instantly share code, notes, and snippets.

@BenjaminVerble
Last active March 31, 2017 16:28
Show Gist options
  • Select an option

  • Save BenjaminVerble/4f9cd35b158cab1eaba76a0cb4f25b94 to your computer and use it in GitHub Desktop.

Select an option

Save BenjaminVerble/4f9cd35b158cab1eaba76a0cb4f25b94 to your computer and use it in GitHub Desktop.

Revisions

  1. BenjaminVerble revised this gist Mar 31, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions simple-join.sql
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,8 @@ VALUES
    ('2134dfg45675fa4352', 'Joe Sixpack')
    ;

    UPDATE authors SET author = 'Fran Sixpack' where id = '2134dfg45675fa4352';

    SELECT
    authors.id, books.title, authors.author
    FROM
  2. BenjaminVerble created this gist Mar 31, 2017.
    27 changes: 27 additions & 0 deletions simple-join.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    CREATE TABLE books
    (author_id varchar(55) PRIMARY KEY, title varchar(55))
    ;
    INSERT INTO books
    ('author_id', 'title')
    VALUES
    ('1asdfasdfasdfasdas', 'How to make your life better'),
    ('asdfasdf23423456gf', 'How to Cook'),
    ('2134dfg45675fa4352', 'Hi, what is your name, I am joe')
    ;

    CREATE TABLE authors
    (id varchar(55), author varchar(55));
    INSERT INTO authors
    ('id', 'author')
    VALUES
    ('1asdfasdfasdfasdas', 'John Smith'),
    ('asdfasdf23423456gf', 'Jane Smith'),
    ('2134dfg45675fa4352', 'Joe Sixpack')
    ;

    SELECT
    authors.id, books.title, authors.author
    FROM
    books
    JOIN authors ON
    books.author_id == authors.id;