views:

55

answers:

2

i have an table

tbl_exp

 id| exp_id|qnty|     last_update
 1 |   12  |  10|2010-05-18 19:34:29
 2 |   13  |  50|2010-05-19 19:34:29
 3 |   12  |  50|2010-05-19 19:34:29
 4 |   15  |  50|2010-05-18 19:34:29
 5 |   18  |  50|2010-05-20 19:34:29
 6 |   13  |  70|2010-05-20 19:34:29

now i need only latest entry of each exp_id

 id| exp_id|qnty|     last_update
 3 |   12  |  50|2010-05-19 19:34:29
 6 |   13  |  70|2010-05-20 19:34:29
 4 |   15  |  50|2010-05-18 19:34:29
 5 |   18  |  50|2010-05-20 19:34:29

please suggest me the mysql query to retrive above result??

thanks!

A: 

http://stackoverflow.com/search?q=max-per-group

Tomalak
This is not duplicate sir?? here qnty in lates row may be less than previous row? so on which attibute i have to select rows??
diEcho
don't refer any link plz
diEcho
Is this some kind of "do my work for me" attitude? You have a common problem, and not even a very complicated one. It has been solved many times on this website alone, all you need to do is apply one of the solutions that are already there and a bit of thinking. And fix your English, this chat style is annoying as hell.
Tomalak
@Tomalak Thanks for suggestion! i"ll keep in mind from now.
diEcho
+1  A: 

This is gone over in detail here: http://stackoverflow.com/questions/1313120/sql-retrieving-the-last-record-in-each-group

I have tested it and it works.

Kerry
is this works then y i asked such a silly question bro??
diEcho
I don't understand what you're asking? Have you tried it? I will remove it if it's not working, but pretty sure I've done the above successfully.
Kerry
Please stop calling people here "bro" and "dear", that's wildly inappropriate.
Tomalak