Jump to content

Retrieve Last Duplicate Record


refiking

Recommended Posts

I have a db field name "id" that is autoincrement and I want to run the query to get the most recent record that matches the query.  What do I need to do to accomplish this?

 

$sql = mysql_query("SELECT * FROM `phplist_user_user` WHERE `email` = '$email'")or die(mysql_error());

Link to comment
Share on other sites

'most recent' implies using some kind of timestamp. You cannot rely on auto_increment to indicate the order in which record were inserted.

 

If you want to take a risk though:

SELECT * FROM `phplist_user_user` WHERE `email` = '$email' ORDER BY id DESC LIMIT 1

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.