Here's the data I have:
PHP Code:
TABLE1
TABLE1ID roomID objectID timeStamp
1 3 5 1254807439
2 3 6 1254807439
3 3 7 1254807439
4 3 8 1254807439
5 3 5 1254287435
6 3 6 1254287435
7 3 7 1254287435
8 3 8 1254287435
9 5 5 1254807439
10 5 6 1254807439
11 5 7 1254807439
12 5 8 1254807439
13 5 5 1254287435
14 5 6 1254287435
15 5 7 1254287435
16 5 8 1254287435
ROOMTABLE
roomID roomLocation roomBuilding roomDescription
3 2.55 m06 First Room
5 1.23 m06 Second Room
6 1.25 m06 Third Room
What I need to do is return the list of rooms and room location, building etc in a table, but ordered either asc or desc by the timestamp. This part I can do. I also need to only return a distinct set of rooms, ie, I can't have duplicated rooms.
So basically, the result from the table above should be:
RESULTS:
PHP Code:
roomID roomLocation roomBuilding roomDescription timestamp
3 2.55 m06 First Room 1254807439
5 1.23 m06 Second Room 1254807439
6 1.25 m06 Third Room 0
When ever I attempt this, using INNER JOIN or LEFT JOIN and connecting up the tables I always get duplicated rooms (Because of the different dates). If I use distinct, I will still get duplicated rooms.
I basically need unique room results, with the latest date.
Could anyone offer any help to achieve this query?