Select with multiple records

2001-12-12 Thread Lindstrom Greg - glinds

Greetings-

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?

Thanks!

Greg Lindstrom
Acxiom Corporation,mail: CWY10011149
InfoBase Products Development  office: (501) 342-1626
301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 
email: [EMAIL PROTECTED]   

Programming requires discipline. Period. If you're depending on a compiler
to catch sloppy thinking, then you've got trouble. John Roth



-
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




Re: Select with multiple records

2001-12-12 Thread rc

can't you select the latest timestamp?

On Wed, 12 Dec 2001, Lindstrom Greg - glinds wrote:

 Greetings-
 
 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?
 
 Thanks!
 
 Greg Lindstrom
 Acxiom Corporation,mail: CWY10011149
 InfoBase Products Development  office: (501) 342-1626
 301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911 
 email: [EMAIL PROTECTED]   
 
 Programming requires discipline. Period. If you're depending on a compiler
 to catch sloppy thinking, then you've got trouble. John Roth
 
 
 
 -
 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
 


-
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




Re: Select with multiple records

2001-12-12 Thread DL Neil

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