Hello All -
I'm trying to join all of the columns in one table (tbl_admin_users) with 2 fields in another table(tbl_access_log) using both a WHERE and ORDER BY clause on tbl_access_log.
So far I can't get my sql statement (shown below) to work.
$sql =
"SELECT *
FROM tbl_admin_users
LEFT JOIN tbl_access_log.fld_login, tbl_access_log.fld_logout
WHERE tbl_access_log.fld_user_id = '" . $adminId . "'
ORDER by tbl_access_log.fld_logout DESC limit 1";
What's going on is that there are multiple rows in tbl_access_log with the same foreign key...
(WHERE tbl_access_log.fld_user_id = '" . $adminId . "')
and what I need to get is a row matching $adminId which also contains the most recent unix timestamp which is found in the fld_logout...
(ORDER by tbl_access_log.fld_logout DESC limit 1)
Can someone show me where I'm going wrong with my sql statement?
All replies greatly appreciated!