Jump to content


Photo

Help is needed in setting an interval


  • Please log in to reply
5 replies to this topic

#1 nemethpeter

nemethpeter
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationHungary >> BudaPest

Posted 10 June 2003 - 08:09 PM

Hello!

THere\'s a table with say 5 columns and 60 rows. How can i make a SELECT query, that selects the rows between 20 and 30? (there are id-s in every rows, but as some are usually deleted, it cannot be said, that rows between the id-s 20 and 30) I know, that there\'s a phrase called \'BETWEEN\', but dunno how may i apply it when talkin about rows...

Bye

NP
It is better to reign in Hell, than to serve in Heaven.

#2 Blu_Smurf

Blu_Smurf
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationTexas

Posted 10 June 2003 - 10:03 PM

Maybe you can run a loop count each row and tell it to display 20-30?

try http://www.mysql.com and run a search there, that site will tell you everything you could ever want to know in plain english, best sitre ever.

#3 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 10 June 2003 - 11:18 PM

Try this

select * from tablename where id BETWEEN 20 and 30

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#4 nemethpeter

nemethpeter
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationHungary >> BudaPest

Posted 11 June 2003 - 12:30 PM

Ya know, the problem is, that some rows might be deleted (just as i said) and the id-s may come like 1,3,4,5,8,10 and in this way saying that \"where id BETWEEN 1 and 10\" certainly doesn\'t produce 10 rows of data.
However, recently I\'ve heard that all rows should be processed, and in the array just the surplus should be deleted... What do you think?

Thanks for the answers:

NP
It is better to reign in Hell, than to serve in Heaven.

#5 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 11 June 2003 - 12:42 PM


SELECT * FROM table ORDER BY id LIMIT 10 OFFSET 20;


will return 10 records starting from record number 20...

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#6 nemethpeter

nemethpeter
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationHungary >> BudaPest

Posted 11 June 2003 - 01:10 PM

Thanks a lut!
Will try that!

ReSPecT:

NP
It is better to reign in Hell, than to serve in Heaven.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users