id userid note created_date
1 100 x 2010-09-29 02:24:57
2 101 y some date
3 100 z some date
4 103 a "
5 100 b "
6 102 c "
I want to latest 2 result of userid 100 and 102. This is the situation to understand the problem. Actually I have a list of userid and I want the latest n result of userid which is in my list of userid.
This was very difficult to understand but I’ll give you three possible answers:
1) If you want the results by the highest user iD (“latest” could mean that), you should do
2) If you want them ordered by creation date (which “latest” could also mean), type
3) if your “list of userid” is another table, you want to join it
If you actually want something else, you’ll have to explain it 🙂