Reading from MySQl DB

Hi Guys

I am entering times from a Biometric device into a DB, that works fine.When I read the times
which has multiple rows per user for a day. eg…


900 2012-25-03 07:00
901 2012-25-03 07:01
900 2012-25-03 13:00
900 2012-25-03 14:00
900 2012-25-03 16:00

What I want is in order to work out the times that has been worked for ID 900 I have to use the first instance and
the last instance for ID 900 for a particular day.

Is there a function available to read only this ?


Not sure about a ‘min’ ‘max’ function for mysql; however, this may get you what you want…

$w_id = 900;
$query ="SELECT id, datetime FROM table_name WHERE id ='$w_id ORDER BY datetime ASC";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
	$data[] = $row['datetime'];
$i = count($data) - 1;
$start_data = $data[0];
$end_data = $data[$i];

Thanks, this is actually a good start for me.I am actually trying to to aviod making multiple SELECT calls, I want to
call the DB once for all 300 employess.

     , MIN(datetime) as earliest
     , MAX(datetime) AS latest
  FROM daTable
    BY id

Thank you Rudy,this works fine