Greg, > I have a MySQL database with a table (job_table) containing information > concerning jobs I run. Among the fields on the table are job_id > (varchar(10)), and timestamp (a timestamp). As I run jobs, I add an entry > to the table with the job_id, timestamp, and associated information, so the > table contains multiple entries for any given job_id. I would like to be > able to run a select on the table to retrieve the latest entry for each > job_id so I can display a "latest status" message for every job. How do I > (assuming that I can) construct the SELECT statement to do this?
=it appears that what you want is to group the job table rows by job_id and then take the most recent row as defined by the timestamp field. =The function required to choose the 'latest' (highest number) timestamp is appropriately enough called MAXIMUM(). In order to get the count to apply to a particular set of job_id rows use the GROUP BY clause (of SELECT). =Please check out the online manual for syntax and wider explanations. =dn --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php