Skip to main content

Posts

Showing posts from 2012

To fetch highest row in table

SELECT * FROM `bids` as b where amount = (select max( amount) from bids where userid = b.userid) and timestamp = (select max( timestamp) from bids where userid = b.userid) group by userid For examples id userid timestamp amount 1 101     1122334  223 2 102     1222334  323 3 101     1322334  523 4 102     1522334  723 5 101     1622334  283 6 102     1722334  293 7 102     1822334  233 8 102     2222334  203 id userid timestamp amount 1 101      1622334 283 2 102      2222334 203