Suppose this is a Table

Create Table Person(
PersonID varchar(8),
PersonLN varchar(16),
PersonFN varchar(16),
PersonADD varchar(64),
PersonPH varchar(16));

so there are many enrty in that table.. So how to select the lastest row entry from that table? what will be the Mysql statement?

take PersonID as a Primary key..........

Re: How to select the Last row from a table..using Mysql 80 80
SELECT *
FROM Person
ORDER BY PersonID DESC
LIMIT 1
commented: nice =D +2
Re: How to select the Last row from a table..using Mysql 80 80

Suppose this is a Table

Create Table Person(
PersonID varchar(8),
PersonLN varchar(16),
PersonFN varchar(16),
PersonADD varchar(64),
PersonPH varchar(16));

so there are many enrty in that table.. So how to select the lastest row entry from that table? what will be the Mysql statement?

take PersonID as a Primary key..........

do you have the values?

Re: How to select the Last row from a table..using Mysql 80 80
Re: How to select the Last row from a table..using Mysql 80 80

Just check out this for getting last updated row
<URL SNIPPED>

commented: Its a 3 yr old dead thread for god's sake! -1
Re: How to select the Last row from a table..using Mysql 80 80

You can use maxdb_insert_id() For the
Getting last record from table..

Ashish Patel

Re: How to select the Last row from a table..using Mysql 80 80

SELECT * FROM Person ORDER BY PersonID DESC LIMIT 1

Ashish Patel

Re: How to select the Last row from a table..using Mysql 80 80

sorry but without an auto-incrementing numerical id, it doesn't look as if sorting will work. It looks like the primary key is PersonID varchar(8),

so id 9a would be rated as a bigger id than id 88888a wouldn't it? That's how it goes with varchar, it's an alphabetical sort, not a numerical one.

How are these varchar ids assigned?? Can they be changed to be auto-incrementing numerical?

And of course this antique thread has been revived by a signature spammer, and the posts should be deleted.

Re: How to select the Last row from a table..using Mysql 80 80

hi guys use the following options

SELECT * FROM `myfield` WHERE `trackid` = '65' ORDER BY `id` DESC LIMIT 0,1

if u doesn't need a 'where' check use the following query

SELECT * FROM `myfield` ORDER BY `id` DESC LIMIT 0,1

Re: How to select the Last row from a table..using Mysql 80 80

Nice Article !

Really this will help to people of MySQL Community.
I have also prepared small note on this, Get last updated id of the MySQL Table.

http://www.dbrnd.com/2015/11/mysql-get-id-of-the-last-updated-row/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.