EXPLAIN EXTENDED

How to create fast database queries

Archive for March 22nd, 2009

Selecting non-unique rows

with one comment

Sometimes we need to select all rows for a table that have duplicate values in some of the columns. Like, we want to select all user comments for all posts commented by more than one user.

If there are two or more comments for a post, we select all comments for this post; if there is only one comment, we select none.

Let's create the sample tables to illustrate our needs:
Read the rest of this entry »

Written by Quassnoi

March 22nd, 2009 at 11:00 pm

Posted in MySQL