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..........

SELECT *
FROM Person
ORDER BY PersonID DESC
LIMIT 1
commented: nice =D +2

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?

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

commented: Its a 3 yr old dead thread for god's sake! -1

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

Ashish Patel

SELECT * FROM Person ORDER BY PersonID DESC LIMIT 1

Ashish Patel

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.

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

Be a part of the DaniWeb community

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