Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm a novice to programming/database administration...is there a MySQL function to find the primary key of the most recent insert/update of a specific column entry?

I have a data base that's using auto_increment as the primary key but one column has multiple entries with the same value but I'm trying to find the MOST RECENT INSERT/UPDATE OF THIS ENTRY.

I know how to write the query to find this but I wanted to know if there's a function.

Here's the query I've written to accomplish the task but if there's a function that does this would someone please let me in on it?

id is the primary key:
Example - SELECT id from table1 WHERE name = "John Doe" ORDER BY id DESC LIMIT 1;
Posted

1 solution

Hi,

read this:
http://forums.mysql.com/read.php?20,125996,125998#msg-125998
[
target="_blank" title="New Window">^
]


you can also search for
Scope_Identity in mysql or MAX in mysql .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900