Dear All,
I have query below as below. The first query give me all the device data together ordered based on tblDevice.dateTime Desc.
“SELECT * from tblDevice order by tblDevice.dateTimer Desc”
The problem is that for each of the device table I have to check another table called as tblMessage. Then I have to check if there is any message in that which have the Date timer value more than the tblDevice then I have to pick that to be shown. Now what I do is first I run the first loop based on tblDevice then I do a logic in the loop run the second query. All works fine the only problem I can not maintain the time sequence. Say for instance 1st data for tblDevice is on 2010-10-20:10:10. Then second data from tblDevice is 2010-10-20:10:05. But for the second data there is a matching data in the tblMessage with the timestamp 2010-10-20:11:00. So when I want to show the data in html table suppose my second data should be first shown but I cannot control that now cause I am constraint based “order by tblDevice.dateTimer Desc”. Any idea please?
“Select * From tblMessage WHERE deviceId”.$dID." and DATE>‘“.$currentDateTimer.”’ order by DATE DESC"
//$dID and $currentDateTimer is from tblDevice when I run the loop.
Thank you.