SELECT query with negative LIMIT?

This is a discussion on SELECT query with negative LIMIT? within the MySQL Database forums, part of the Database Forums category; Is possible execute the query below: SELECT * FROM table LIMIT -10 I need extract the last 10 rows inserted in ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-07-2007
antoniog
 
Posts: n/a
Default SELECT query with negative LIMIT?

Is possible execute the query below:

SELECT * FROM table LIMIT -10

I need extract the last 10 rows inserted in table.

That query running?

Thank you for all

antoniog
Reply With Quote
  #2 (permalink)  
Old 03-07-2007
Paul Lautman
 
Posts: n/a
Default Re: SELECT query with negative LIMIT?

antoniog wrote:
> Is possible execute the query below:
>
> SELECT * FROM table LIMIT -10
>
> I need extract the last 10 rows inserted in table.
>
> That query running?
>
> Thank you for all
>
> antoniog


Use an auto_increment column and sort DESC then use limit 10


Reply With Quote
  #3 (permalink)  
Old 03-07-2007
Rik
 
Posts: n/a
Default Re: SELECT query with negative LIMIT?

antoniog <agpquota@tucerchinoitroviamo.com> wrote:

> Is possible execute the query below:
>
> SELECT * FROM table LIMIT -10
>
> I need extract the last 10 rows inserted in table.


Hmmz, I assume there's some way the 'last rows' can be selected by a
field, either a unique incrementing 'id', or some sort of 'add_time'

SELECT * FROM TABLE ORDER BY id DESC LIMIT 10

--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel
Reply With Quote
  #4 (permalink)  
Old 03-07-2007
antoniog
 
Posts: n/a
Default Re: SELECT query with negative LIMIT?

Thank you

I will try it

Paul Lautman ha scritto:
> antoniog wrote:
>> Is possible execute the query below:
>>
>> SELECT * FROM table LIMIT -10
>>
>> I need extract the last 10 rows inserted in table.
>>
>> That query running?
>>
>> Thank you for all
>>
>> antoniog

>
> Use an auto_increment column and sort DESC then use limit 10
>
>

Reply With Quote
  #5 (permalink)  
Old 03-07-2007
antoniog
 
Posts: n/a
Default Re: SELECT query with negative LIMIT?

Thank you

I will try it

Rik ha scritto:
> antoniog <agpquota@tucerchinoitroviamo.com> wrote:
>
>> Is possible execute the query below:
>>
>> SELECT * FROM table LIMIT -10
>>
>> I need extract the last 10 rows inserted in table.

>
> Hmmz, I assume there's some way the 'last rows' can be selected by a
> field, either a unique incrementing 'id', or some sort of 'add_time'
>
> SELECT * FROM TABLE ORDER BY id DESC LIMIT 10
>
> --Rik Wasmus
> Posted on Usenet, not any forum you might see this in.
> Ask Smart Questions: http://tinyurl.com/anel

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:45 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0