daydreamer Posted November 21, 2008 Share Posted November 21, 2008 How can I get the latest insert of a certain record in mysql. example table: id user date 1 smokey ... 2 Jsmith ... 3 Blondy ... 4 dexter ... 5 Blondy ... 6 tt ... I am after row id:5 user:Blondy only. I could do this: $last = mysql_query("SELECT * FROM members WHERE user='Blondy' ") or die (mysql_error()); then get the biggest ID and thats the row i need, but im sure there is a way to do it in one mysql query? Thanks any help appreciated. Link to comment https://forums.phpfreaks.com/topic/133705-mysql-query/ Share on other sites More sharing options...
Mark Baker Posted November 21, 2008 Share Posted November 21, 2008 Try $last = mysql_query("SELECT * FROM members ORDER BY ID DESC LIMIT 1") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/133705-mysql-query/#findComment-695763 Share on other sites More sharing options...
revraz Posted November 21, 2008 Share Posted November 21, 2008 $last = mysql_query("SELECT * FROM members WHERE user='Blondy' ORDER BY ID DESC LIMIT 1") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/133705-mysql-query/#findComment-695829 Share on other sites More sharing options...
daydreamer Posted November 21, 2008 Author Share Posted November 21, 2008 lol thanks alot, i just came across an error and that was the problem! cheers. Link to comment https://forums.phpfreaks.com/topic/133705-mysql-query/#findComment-695858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.