List:General Discussion« Previous MessageNext Message »
From:Dotan Cohen Date:October 20 2011 12:09am
Subject:Re: How to select the id of 2+ records for given user?
View as plain text  
On Thu, Oct 20, 2011 at 00:06, Basil Daoust <bdaoust@stripped> wrote:
> For me given the sample data the following worked.
> The inner select says find all first messages, the outer says give me all
> messages that are thus not first messages.
>
> select * from table1 where messageID NOT IN (
> select messageID from table1
> group by userID
> )
>
> Some times just playing with the data will result in an aha moment.

Wow, nice! That looks to be the elegant, simple solution that I do
need. The real-world example is more contrived but I should be able to
use this method to do it cleanly. It will involve a sort and a limit
on the inner select. Thanks!


> I'm assuming where you show row 7 you meant row 8?
>

Yes, that is what I meant. As someone wiser than myself once said: to
err is human, but to really mess things up we need a computer!


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
Thread
How to select the id of 2+ records for given user?Dotan Cohen19 Oct
  • Re: How to select the id of 2+ records for given user?Michael Dykman19 Oct
    • Re: How to select the id of 2+ records for given user?Derek Downey19 Oct
      • Re: How to select the id of 2+ records for given user?Basil Daoust20 Oct
        • Re: How to select the id of 2+ records for given user?Derek Downey20 Oct
          • Re: How to select the id of 2+ records for given user?Dotan Cohen20 Oct
        • Re: How to select the id of 2+ records for given user?Dotan Cohen20 Oct
        • Re: How to select the id of 2+ records for given user?hsv20 Oct
          • Re: How to select the id of 2+ records for given user?Dotan Cohen21 Oct