oh not him again

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Deddog
Forum Commoner
Posts: 55
Joined: Thu Sep 26, 2002 6:05 am
Location: Brighton

oh not him again

Post by Deddog »

How can i extract the most recent and last entered bit of data from the below returned results, or how can i modify this statement to only bring back the most last enetered row?


Php/Mysql

$sql = "select booked.*, rooms.RoomName, rooms.GuardianId from booked LEFT JOIN rooms
ON booked.RoomsId = rooms.RoomsId
WHERE booked.WhoId = '$EmployeeId' AND booked.BookedDate = '$ReturnDate' and BookedTime = '$TimesAM' ";
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

By order and limit

$sql = "select booked.*, rooms.RoomName, rooms.GuardianId from booked LEFT JOIN rooms
ON booked.RoomsId = rooms.RoomsId
WHERE booked.WhoId = '$EmployeeId' AND booked.BookedDate = '$ReturnDate' and BookedTime = '$TimesAM' order by BookedTime DESC LIMIT 1";
Deddog
Forum Commoner
Posts: 55
Joined: Thu Sep 26, 2002 6:05 am
Location: Brighton

ah ha

Post by Deddog »

Once again, thank you :)
Post Reply