943,910 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 121071
  • MySQL RSS
Jul 26th, 2006
0

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

Expand Post »
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..........
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mishu007 is offline Offline
2 posts
since Jul 2006
Jul 26th, 2006
1

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

MySQL Syntax (Toggle Plain Text)
  1. SELECT *
  2. FROM Person
  3. ORDER BY PersonID DESC
  4. LIMIT 1
Last edited by stymiee; Jul 26th, 2006 at 11:10 am.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Nov 28th, 2006
0

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

Click to Expand / Collapse  Quote originally posted by mishu007 ...
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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hazel_0821 is offline Offline
5 posts
since Nov 2006
Nov 29th, 2006
0

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

Reputation Points: 529
Solved Threads: 10
Posting Pro in Training
Sulley's Boo is offline Offline
450 posts
since Dec 2004
Nov 7th, 2009
-2
Re: How to select the Last row from a table..using Mysql
Just check out this for getting last updated row
<URL SNIPPED>
Last edited by peter_budo; Nov 8th, 2009 at 4:39 am. Reason: Keep It On The Site - Posts must contain actual content and substance and cannot simply be external links.
Reputation Points: 9
Solved Threads: 1
Newbie Poster
avinashzala is offline Offline
4 posts
since Nov 2009
Jan 25th, 2011
0
Re: How to select the Last row from a table..using Mysql
You can use maxdb_insert_id() For the
Getting last record from table..

Ashish Patel
Last edited by Ezzaral; Jan 26th, 2011 at 4:09 pm. Reason: Snipped "fake sig" link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
technoempire is offline Offline
4 posts
since Jan 2011
Jan 25th, 2011
0
Re: How to select the Last row from a table..using Mysql
SELECT * FROM Person ORDER BY PersonID DESC LIMIT 1

Ashish Patel
Last edited by Ezzaral; Jan 26th, 2011 at 4:10 pm. Reason: Snipped "fake sig" link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
technoempire is offline Offline
4 posts
since Jan 2011
Jan 25th, 2011
0
Re: How to select the Last row from a table..using Mysql
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.
Reputation Points: 76
Solved Threads: 78
Posting Pro in Training
drjohn is offline Offline
423 posts
since Mar 2010
Nov 17th, 2011
0
Re: How to select the Last row from a table..using Mysql
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
charles_7 is offline Offline
1 posts
since Nov 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Retrieve data based on date
Next Thread in MySQL Forum Timeline: Relating Master database and child database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC