List:General Discussion« Previous MessageNext Message »
From:Bryan Cantwell Date:September 10 2010 5:12pm
Subject:Get max ID of each item in a list
View as plain text  
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?


Thread
Get max ID of each item in a listBryan Cantwell10 Sep
  • Re: Get max ID of each item in a listKévin Labécot10 Sep