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. Quote Link to comment 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()); Quote Link to comment 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()); Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.