Try...
SELECT location FROM kanban_cards a WHERE id IN(SELECT Max(id) FROM kanban_cards b WHERE a.part = b.part AND a.kan_number = b.kan_number) ORDER BY part, kan_number; Eddy On Fri, 2004-11-05 at 14:27, John Wall wrote: > I am using 4.1 with inner joins, and my query is taking about 9.4 > seconds to excute now. I used looping functions before in php, but I > wanted one sql to do it all > > SELECT location FROM kanban_cards WHERE id IN(SELECT Max(id) FROM > kanban_cards GROUP BY part, kan_number ORDER BY part, kan_number); > > My table holds scan events, each card has a part number, and kan > number. Each scan is a row, and the table holds several of the same > part/card/locations, but at different dates. I need to select the most > current row, one from each card, to get the current information of > where they are in the plant. > > Fields in kanban_card > > part - text > kan_number - int > location - int > datestamp - date > id - autonumber > > -- Edward A. Macnaghten http://www.edlsystems.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]