Jump to content

MAX Date


Donn

Recommended Posts

Hi,

I have the below query and it works, however I need the emp.Date to be MAX Date as I want the last time that the person logged in, the below code shows the first time they logged in.

Could anyone please help, I have tried and got good advise already but stuck on this last hurdle.

cheers


<?
$query = "SELECT emp.Date, emp.Passcode, emp2.Surname, emp.status
FROM emp INNER JOIN emp2 ON emp.Passcode = emp2.Passcode GROUP BY emp.Passcode ";

$result = mysql_query($query);
$newline = "<br />";
while($row = mysql_fetch_array($result)){
echo "". $row['Passcode']." " .$row['Surname']. " " .$row['Date']." " .$row['status'];
echo "<br />";
}
?>
Link to comment
Share on other sites

[quote author=fenway link=topic=118882.msg486218#msg486218 date=1166292403]
So why not:

[code]
SELECT MAX(emp.Date) AS maxDate, emp.Passcode, emp2.Surname, emp.status
FROM emp INNER JOIN emp2 ON emp.Passcode = emp2.Passcode GROUP BY emp.Passcode
[/code]
[/quote]

Hi,
This does not work,

I used to get a result like
1111 Hutchinson 2006-12-14 22:33:07 In
2222 Corkish 2006-12-12 23:02:56 Out
3159 Houldsworth 2006-12-14 07:47:18 Out
3333 Kelly 2006-12-14 22:33:27 Out
14789 Fox 2006-12-15 10:30:39 In

Now I get
1111 Hutchinson In
2222 Corkish Out
3159 Houldsworth Out
3333 Kelly Out
14789 Fox In

it still shows the first record in the table not the last of each person also no time?

|I am really stumped on this. Any help appreciated.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.