On Mon, Mar 30, 2009 at 7:55 AM, Sebastian Muszytowski
<s.muszytow...@googlemail.com> wrote:
> Thijs Lensselink schrieb:
>>
>> Sebastian Muszytowski wrote:
>>
>>>
>>> Hello :)
>>>
>>> I have some troubles with php and mysql.  I have a normal MySQL Query
>>> and this returns X > 3 rows.
>>> Now i want to get the last 3 inserted values. For Example i've inserted
>>>
>>> A, B, C, D, E
>>>
>>> I want to get the last inserted values, e.g. E D C (in reversed order)
>>>
>>> So how to do this? I already searched the web and the whole php.net site
>>> but i don't see any workaround.
>>>
>>> Thanks in advance
>>>
>>> Sebastian
>>>
>>>
>>>
>>
>> It's not really a PHP question. But here goes :
>>
>> SELECT column FROM `table` ORDER BY column DESC LIMIT 3
>>
>
> Oh okay thank you very much :)
>
> I thought I must do this with php and some sort of mysql_fetch_asssoc or
> something like this

Except when your primary key value rolls over, or fills a gap between
two other rows that was left when a row was deleted/moved/etc... there
has got to be a better way than grabbing rows in descending order
based on the auto_increment value.

Are you doing the inserts one at a time? If so, why not just use code
to remember what you put in the DB?


-- 
// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to