Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

sql, getting the latest id from a table

Posted on 2011-05-04
2
Medium Priority
?
467 Views
Last Modified: 2012-05-11
I am using postgres.

I have a table called MyTable with id as the primary key, and it is incrementing of course.  How do I get the latest id (or the largest id)?

Also, how do I get the latest row?
0
Comment
Question by:rgbcof
2 Comments
 
LVL 41

Accepted Solution

by:
Sharath earned 1000 total points
ID: 35695982
select max(ID) from MyTable
0
 

Author Closing Comment

by:rgbcof
ID: 35696005
Perfect.  Thank you
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Screencast - Getting to Know the Pipeline

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question