| List: | General Discussion | « Previous MessageNext Message » | |
| From: | (Hal | Date: | October 20 2011 2:08pm |
| Subject: | Re: How to select the id of 2+ records for given user? | ||
| View as plain text | |||
;>>> 2011/10/19 17:06 -0500, Basil Daoust >>>> 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 ) <<<<<<<< Well done--but.... Although, it seems, it is everyone s experience that the desired order is the order that MySQL yields, all guarantee of that is explicitly deny'd (look up 'GROUP BY'). It is better to be safe and to use "MIN": select * from table1 where messageID NOT IN ( select MIN(messageID) from table1 group by userID )
| Thread | ||
|---|---|---|
| • How to select the id of 2+ records for given user? | Dotan Cohen | 19 Oct |
| • Re: How to select the id of 2+ records for given user? | Michael Dykman | 19 Oct |
| • Re: How to select the id of 2+ records for given user? | Derek Downey | 19 Oct |
| • Re: How to select the id of 2+ records for given user? | Basil Daoust | 20 Oct |
| • Re: How to select the id of 2+ records for given user? | Derek Downey | 20 Oct |
| • Re: How to select the id of 2+ records for given user? | Dotan Cohen | 20 Oct |
| • Re: How to select the id of 2+ records for given user? | Dotan Cohen | 20 Oct |
| • Re: How to select the id of 2+ records for given user? | hsv | 20 Oct |
| • Re: How to select the id of 2+ records for given user? | Dotan Cohen | 21 Oct |
