PHP: get the last row in database using mysql
I've been thinking this whole day and yet I can't find the correct query.
I already search to google and tried to used the "DESC" or "DESC LIMIT 1"
but still its not working.
So, here's my scenario:
I'm planning to get the last row of my table and its always displaying the
result of the middle table...
Example:
I have a 3 rows in my table of tbldata.
0:5
0:10
0:15
here's my query for that:
$result = mysql_query(
"SELECT fldBldgName, fldTimestamp,
MIN(fldTotalDuration)fldTotalDuration
FROM tbldata
WHERE fldNetname = '".$network."'
AND fldBldgName = '".$bldg[$i]."'
AND fldWeek = '".$week."'
AND fldMonth = '".$month."'
GROUP BY fldBldgName
ORDER BY fldBldgName,fldTimestamp, fldTotalDuration DESC");
I already tried also the ID to order by but still its not working.. I
already tried the timestamp but still its not working.
The result for that query is always the "0:10", the correct output should
be "0:15".
But then if I have 2 rows only:
0:5
0:10
the result is : 0:10 which is correct
And so, I also tried it to manually query it in phpmyadmin still not
displaying the last row...
Thanks for the help...
No comments:
Post a Comment