[GLLUG] mysql help

Jason Justman justmanj@msu.edu
Thu, 27 Jun 2002 15:22:01 -0400


a better way is:

SELECT * FROM table ORDER BY id DESC;

j


Brian Hoort wrote:

> Shouldn't you be looking for the max (highest) value of the record id? 
> It is my understanding that they never re-use old numbers.
> Something like:
> SELECT * FROM $table WHERE id=max(id)
>
> I'm an SQL newbie, so take this with a grain of salt...
>
> At 03:02 PM 6/27/2002, you wrote:
>
>> I'm trying to select the last row in a table...can anyone provide 
>> some help
>> with this.
>>
>> something like...  SELECT last_row FROM $table  or SELECT * FROM $table
>> WHERE last_row
>>
>> I realize that this isn't the proper syntax...any help would be 
>> appreciated.
>> Maybe you can actually come up with a better way of doing what I'm 
>> trying to
>> do.  I am entering info into a table from a web-based form with PHP.  
>> The
>> table has an ID field which is auto_increment.  I need to get the ID 
>> value
>> of the row that was just entered by the current script, later in the 
>> script.
>> It _should_ be the last row in the table and that's why I'm trying to
>> extract it that way...I'm sure there must be a better way to do this.
>> Thanks in advance for the help!
>>
>> -Adam
>>
>>
>>
>>
>> _______________________________________________
>> linux-user mailing list
>> linux-user@egr.msu.edu
>> http://www.egr.msu.edu/mailman/listinfo/linux-user
>
>
> _______________________________________________
> linux-user mailing list
> linux-user@egr.msu.edu
> http://www.egr.msu.edu/mailman/listinfo/linux-user