This is my table structure -
TABLE : COURSE_LOG
-----------------------------------------------------
| ID | USERNAME | COURSE_ID | LDATE |
Try this query
If you want only for user1
then use this query:
select username, course_id, max(ldate) as date
from tbl
where username='user1'
group by username, course_id
| USERNAME | COURSE_ID | DATE |
-------------------------------------
| user1 | 22 | 2013-06-03 |
| user1 | 54 | 2013-06-03 |
If you want to find the latest date for all users then use this query
select username, course_id, max(ldate) as date
from tbl
group by username, course_id
In this query data of user2
will also be included
| USERNAME | COURSE_ID | DATE |
-------------------------------------
| user1 | 22 | 2013-06-03 |
| user1 | 54 | 2013-06-03 |
| user2 | 71 | 2013-06-04 |