SQL: getting the most recent row out of duplicate rows

Hey. I’m trying to get the most recent row from my table. I do have duplicate data in it, and thats whats throwing me off.

This is a basic veiw of what my table looks like…

timestamp ip FILE member
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959588+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959588 | 85.206.12.39 | /cp.php | 176
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+%60usersonline%60+WHERE+%60timestamp%60+%3D+1139959589+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560usersonline%2560%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959589 | 81.202.86.237 | /url.php | 107
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+%60usersonline%60+WHERE+%60timestamp%60+%3D+1139959590+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560usersonline%2560%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959590 | 82.252.48.145 | /contact.php | 138
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+%60usersonline%60+WHERE+%60timestamp%60+%3D+1139959594+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560usersonline%2560%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959594 | 201.243.49.214 | /url.php | 180
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+%60usersonline%60+WHERE+%60timestamp%60+%3D+1139959599+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560usersonline%2560%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959599 | 213.186.170.231 | /url.php | 177
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959600+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959600 | 83.44.117.220 | /faq.php | 182
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959601+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959601 | 85.206.12.39 | /url.php | 109
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959602+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959602 | 201.243.49.214 | /index.php | 120
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959604+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959604 | 85.206.12.39 | /url.php | 182
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959607+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959607 | 81.202.86.237 | /index.php | 107
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959608+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959608 | 85.206.12.39 | /url.php | 132
[URL=“http://66.98.252.78:2082/sql.php?lang=en-utf-8&server=1&collation_connection=utf8_general_ci&db=adcore&table=usersonline&pos=0&session_max_rows=30&disp_direction=horizontal&repeat_cells=100&dontlimitchars=0&sql_query=DELETE+FROM+`usersonline`+WHERE+`timestamp`+%3D+1139959611+LIMIT+1&zero_rows=The+row+has+been+deleted&goto=sql.php%3Flang%3Den-utf-8%26server%3D1%26collation_connection%3Dutf8_general_ci%26db%3Dadcore%26table%3Dusersonline%26pos%3D0%26session_max_rows%3D30%26disp_direction%3Dhorizontal%26repeat_cells%3D100%26dontlimitchars%3D0%26sql_query%3DSELECT%2B%2A%2BFROM%2B%60usersonline%60%2BWHERE%2B1%26zero_rows%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_properties.php”]1139959611 | 213.186.170.231 | /register.php | 174

ok, so what i’m trying to do, is getting what file which ip is currently on, so i need to fine the MAX(timestamp) for each ip, and get the FILE field, but i running into trouble.

This is the command im using now…
SELECT MAX( timestamp ) , FILE , member, ip FROM usersonline GROUP BY ip ORDER BY timestamp DESC

but its gettign the max(timestamp), but not the FILE that goes along with that timestamp.

Thanks.
_naaman