List:General Discussion« Previous MessageNext Message »
From:mfatene Date:May 10 2005 1:37pm
Subject:Re: SELECT Row Numbers?
View as plain text  
Hi,
Have you forgotten what's a primary key ?

Using order by will sort data, and if it's already sorted, it will be sorted
again. Time, memory and maybe disk io.

Using the marco example, i gaved a solution considering iy's what he wants. Till
now i don't know if it's ok or not.

if so, just add :
select * from temp order by Id LIMIT 3,4;

if no, the primary key index will give you the order.

Mathias



Selon Rhino <rhino1@stripped>:

> You should never assume that an SQL query will return data in any specific
> order *unless* you use an ORDER BY to force the sequence of rows in the
> result set.
>
> Data returned by a query will sometimes appear to come out in a particular
> order but you should always view this as a lucky coincidence, not something
> that is guaranteed to happen.
>
> Rhino
>
> ----- Original Message -----
> From: "Marco Neves" <mpneves@stripped>
> To: <mysql@stripped>
> Sent: Tuesday, May 10, 2005 7:14 AM
> Subject: Re: SELECT Row Numbers?
>
>
> > oix ppl,
> >
> > now I have a question.
> >
> > I thougth that when you make a SELECT without an ORDER BY, the rows were
> > returned in natural order, that would be some specific order (insertion
> > order, presence in file, I don't know, but the order would be always the
> > same).
> >
> > Is this uncorrect?
> >
> > Is the returning order variable?
> >
> > Thanks,
> >
> > mpneves
> >
> > On Tuesday 10 May 2005 10:37, Harald Fuchs wrote:
> > > In article <1115681350.427ff24647102@stripped>,
> > >
> > > mfatene@stripped writes:
> > > > hi,
> > > > your need is:
> > > > select * from temp LIMIT 3,4;
> > > > -- 3 because you have to take the fourth and 4 because dist=3+1
> > >
> > > This does not make sense.  A SELECT without an ORDER BY returns the
> > > rows in some undefined order.  If you use "LIMIT 3,4" without ORDER BY,
> you
> > > get four rows out of an unordered set, so it's virtually identical to
> > > "LIMIT 4".  As long as the original poster doesn't say what ordering
> > > he wants, there's no way to tell him a solution.
> >
> > --
> > Marco Paulo Neves
> > MySQL Core Certified
> > Linux Certified Professional
> > http://themage.bliker.com
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.308 / Virus Database: 266.11.6 - Release Date: 06/05/2005
> >
> >
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.11.8 - Release Date: 10/05/2005
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


Thread
SELECT Row Numbers?Chris10 May
  • Re: SELECT Row Numbers?mfatene10 May
    • Re: SELECT Row Numbers?Chris10 May
  • Re: SELECT Row Numbers?Harald Fuchs10 May
    • Re: SELECT Row Numbers?Marco Neves10 May
    • Re: SELECT Row Numbers?Chris10 May
      • Re: SELECT Row Numbers?SGreen10 May
        • Re: SELECT Row Numbers?Chris10 May
  • Re: SELECT Row Numbers?Rhino10 May
    • Re: SELECT Row Numbers?mfatene10 May
  • Re: SELECT Row Numbers?Harald Fuchs10 May
    • Re: SELECT Row Numbers?Alec.Cawley10 May
    • Re: SELECT Row Numbers?Harald Fuchs10 May
      • Re: SELECT Row Numbers?Eric Bergen10 May