SELECT tid,max(id) FROM mytable GROUP BY tid Le 10 sept. 2010 à 19:12, Bryan Cantwell a écrit :
> I have a simple table > > mytable > id int > time_stamp tiemstamp > value int > tid int > > I want to find the max id for each individual tid in my table. > > if I did it one by one it would be: > select max(id) from mytable where tid = 12345; > > but how can I do something more like: > select concat(tid,':',id) from mytable where tid in (123,124,125,126); > > Above is obviously wrone, because what I want is 1 row for each tid in > my 'in' clause that is the max id for that tid.: > > tid:id -> 123:8 for instance. > > Maybe a group by or something? > -- Kévin Labécot -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org