LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-12-2005, 12:14 PM   #1
AQG
Member
 
Registered: Jun 2005
Distribution: SuSE, Red Hat
Posts: 162

Rep: Reputation: 30
Finding the last record on a MySQL table?


Hi can some one enlighten me with an instruction to find the last record on a mysql table.
thanks
 
Old 07-12-2005, 02:36 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Define "last"... the order in which records are stored is arbitrary. Do you mean greatest by a particular index?
Code:
SELECT column1,column2 FROM tablename ORDER BY indexcolumn DESC LIMIT 1;
 
Old 07-13-2005, 10:41 AM   #3
AQG
Member
 
Registered: Jun 2005
Distribution: SuSE, Red Hat
Posts: 162

Original Poster
Rep: Reputation: 30
Ok, thanks, i've got it, but now i have another question:

i've used in one of my tablesa field that contains an id number which automaticly increments every time i add a record to the table, but my problem now is that if i erase the records i have in the table when i insert a new record the id number doesn't start from 1 it starts for example in 20 because i had erased 19 records before.
any suggestions on how to clear that problem?

thanks in advance!!!!1
 
Old 07-13-2005, 10:55 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
The current value of the auto_increment column is stored in the table descriptions in MySQL. The only way (that I know of) to reset it is to drop the table and re-create it from scratch.
 
Old 07-13-2005, 11:44 AM   #5
AQG
Member
 
Registered: Jun 2005
Distribution: SuSE, Red Hat
Posts: 162

Original Poster
Rep: Reputation: 30
OK THANK YOU!!!!

UNTIL NEXT TIME
 
Old 07-13-2005, 12:55 PM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
No problem. Just glad I was able to help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
add/delete record in mysql table on linux from a WinXp machine using visual c++ SyncMaster Linux - Enterprise 2 05-30-2005 12:53 AM
Finding Partition Magic table in FC3install kiwibird Fedora - Installation 0 02-02-2005 04:26 PM
MySQL non-realtime table-by-table mirroring Passive Linux - Software 1 01-20-2004 12:11 PM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 11:30 AM
deleted mysql table in mysql now cant do anything nakkaya Linux - Software 0 03-18-2003 06:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration