Skip to content

Instantly share code, notes, and snippets.

@jodosha
Created November 5, 2008 10:56
Show Gist options
  • Save jodosha/22311 to your computer and use it in GitHub Desktop.
Save jodosha/22311 to your computer and use it in GitHub Desktop.
# SQLite 3
SELECT * FROM "articles" INNER JOIN "articles_categories" ON "articles".id = "articles_categories".article_id WHERE ("articles_categories".category_id = 1 )
+-----+-----------------+---------------------+---------------------+----+------------+-------------+
| id2 | title | created_at | updated_at | id | article_id | category_id |
+-----+-----------------+---------------------+---------------------+----+------------+-------------+
| 2 | Cached Models | 2008-11-05 10:28:10 | 2008-11-05 10:28:10 | 1 | 2 | 1 |
| 1 | Rails Conf 2009 | 2008-11-05 10:28:10 | 2008-11-05 10:28:10 | 2 | 1 | 1 |
+-----+-----------------+---------------------+---------------------+----+------------+-------------+
# MySQL
SELECT * FROM `articles` INNER JOIN `articles_categories` ON `articles`.id = `articles_categories`.article_id WHERE (`articles_categories`.category_id = 1 )
+----+-----------------+---------------------+---------------------+----+------------+-------------+
| id | title | created_at | updated_at | id | article_id | category_id |
+----+-----------------+---------------------+---------------------+----+------------+-------------+
| 2 | Cached Models | 2008-11-05 11:06:43 | 2008-11-05 11:06:43 | 1 | 2 | 1 |
| 1 | Rails Conf 2009 | 2008-11-05 11:06:43 | 2008-11-05 11:06:43 | 2 | 1 | 1 |
+----+-----------------+---------------------+---------------------+----+------------+-------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment