Federal09
Federal09

Reputation: 649

Get last line Column on MySql

I have 1 column name: PersonID it contain name ex john doe

Table name: Person
Column name: PersonID

line1: John Doe
line2: Doe john

now to extract the last line?

this code return number of total line but not text of line

SELECT "PersonID", COUNT(*) FROM "Person";

Upvotes: 0

Views: 1753

Answers (2)

Drew Noakes
Drew Noakes

Reputation: 311245

Order descending, then use the limit to return the last row -- now in the first position!

SELECT *
FROM Person
ORDER BY PersonId DESC
LIMIT 1

Upvotes: 4

Gusti Arya
Gusti Arya

Reputation: 1301

select * from Person order by PERSONID DESC Limit 0,1

Upvotes: 1

Related Questions