Skip to content

Instantly share code, notes, and snippets.

@chiragmongia
Created February 23, 2013 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiragmongia/5019490 to your computer and use it in GitHub Desktop.
Save chiragmongia/5019490 to your computer and use it in GitHub Desktop.
desc user_type;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| usertype | varchar(20) | YES | | NULL | |
| user | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
desc user_category;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| user | varchar(20) | YES | | NULL | |
| article | varchar(20) | YES | UNI | NULL | |
| category | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
desc article_comments;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| article | varchar(20) | YES | | NULL | |
| comments | varchar(30) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
1. select article from user_category where user='user1';
2. select article_comments.article, comments from article_comments inner join user_category on article_comments.article=user_category.article where user='user3';
3. select article from article_comments where ISNULL(comments);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment