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>" Thanks again, Joao. Em Ter, 2004-11-23 ąs 09:57, [EMAIL PROTECTED] escreveu: > I think the reason nobody has replied is that the term "row number" does > not really have any meaning in a DBMS. How the database stores rows > inteneally is the DBMS's private business, and should not be visible to > you. I think it is true that MySQL does not *have* an internal row number, > so there is nothing to skip by. All it stores in MyISAM table is file > offsets. However, even if I am wrong, it doesn't matter: that is an > internal implementation detail and should not be visible to you. > > However, if I read you rightly, what you want it to extract a random tenth > of your table. You could do this by something like > SELECT <columns> FROM <table> ORDER BY rand() LIMIT <table size / 10> ; > > > Joćo Borsoi Soares <[EMAIL PROTECTED]> wrote on 23/11/2004 > 11:30:26: > > > No body has answered my question so far. Does that mean there is no way > > to retrieve current row numbers in a query or no way to retrieve results > > jumping steps? > > > > I would appreciate any help. > > > > Thanks, > > Joao. > > > > -----Mensagem encaminhada----- > > > From: Joćo Borsoi Soares <[EMAIL PROTECTED]> > > > To: [EMAIL PROTECTED] <[EMAIL PROTECTED]> > > > Subject: row numbers, jumping rows > > > Date: Sun, 21 Nov 2004 11:23:41 -0200 > > > > > > Hello list, > > > > > > I wonder if someone could help me to get the fastest result on my > query. > > > I need to classify one entity, according to a specific attribute > (let's > > > call it X), looking at a sample extracted from a database table. > > > First I need to sort my sample ordered by a specific table field (X). > > > Then I should divide my sorted sample in 10 equal groups (same number > of > > > rows). Finally, I should classify my entity (1 to 10), finding out at > > > which group its attribute X fits in. > > > > > > Let me explain my thoughts. First I should make a "SELECT COUNT(*).." > to > > > find the total number of rows in my sample. Then I make queries using > > > LIMIT until I find which group the X attribute fits in. In the worst > > > case I will have to do 10 queries. Which I think should take too long > in > > > my case. > > > > > > I wanted to make it in only one query. It could be possible if I could > > > make a query which returns result jumping rows, like "STEP N" where > "N" > > > could be the number of items in each group. Is there anything in mysql > > > that can give me that? I also thought if I could have the row numbers > in > > > the query result, I could solve it with a simple condition like, > "WHERE > > > rowNum % N = 0". > > > > > > Any ideas? > > > > > > Thanks. > > > > > > > > > > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]