Jo�o Borsoi Soares <[EMAIL PROTECTED]> wrote on 23/11/2004
12:34:01:
> First thanks for the answer Alec. But I think you didn't understood my
> problem. Maybe nobody replied because of that. Let me try again.
>
> Suppose I make a select which returns 100 ordered rows. I only want to
> read rows number 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100.
>
> To read the 10th row I would make "SELECT <columns> FROM <table> ORDER
> BY <my_field> LIMIT 10". To read the 20th it would be "SELECT <columns>
> FROM <table> ORDER BY <my_field> LIMIT 10,10". And so on..
>
> What I want is to make all of these queries in only one.
>
> That's why I said if I could get the row number retrieved from the
> query, I could do: "SELECT <columns> FROM <table> WHERE (rowNumber %
> (tableSize/10)) = 0 ORDER BY <my_field>"
I am not a real MySQL wizard, so there may be better ways. But the way I
would do it would be with a temporary table. This may sound cumbersome,
but as far as I can see MySQL would have to create a temporary table
internally to satisfy your request anyway.
CREATE TEMPORARY TABLE temp
{row INT AUTOINCREMENT NOT NULL,
<other columns as you need>
) ;
INSERT INTO temp SELECT NULL< <other columns> FROM <table> ORDER BY
<criterion> ;
SELECT <columns> FROM temp WHERE row % 10 = 0 LIMIT <as needed> ;
DROP TABLE temp ;
A bit clunky, I agree, but the only way I can see of solving your problem
;
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]