Thread: restircting rows

restircting rows

From
"padmanabha konkodi"
Date:
<p>   <br />   <br /> hi all,<br /><br /> my query return 100 rows but if i am intrested only from 40-60 rows then how
torestrict.<br /><br /> for example<br /><br /> select * from students (returns 100 rows).but i am intrested only rows
from40 to 60. <br /><br /><a
href="http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.rediff.com/signature-home.htm/1507191490@Middle5?PARTNER=3"><img
border="0"hspace="0"
src="http://adworks.rediff.com/cgi-bin/AdWorks/sigimpress.cgi/www.rediff.com/signature-home.htm/1963059423@Middle5?OAS_query=null&PARTNER=3"
vspace="0"/></a> 

Re: restircting rows

From
"A. Kretschmer"
Date:
am  22.02.2006, um  9:06:57 -0000 mailte padmanabha konkodi folgendes:
>   
>   
> hi all,
> 
> my query return 100 rows but if i am intrested only from 40-60 rows then how to restrict.
> 
> for example
> 
> select * from students (returns 100 rows).but i am intrested only rows from 40 to 60.

select * from students limit 20 offset 40;


HTH, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net===    Schollglas Unternehmensgruppe    === 


Re: restircting rows

From
Richard Huxton
Date:
padmanabha konkodi wrote:
> 
> 
> hi all,
> 
> my query return 100 rows but if i am intrested only from 40-60 rows
> then how to restrict.
> 
> for example
> 
> select * from students (returns 100 rows).but i am intrested only
> rows from 40 to 60.

SELECT * FROM student ORDER BY something LIMIT 20 OFFSET 40;

Be aware that this will have to fetch 60 rows and throw the first 40 away.


--   Richard Huxton  Archonet Ltd


Re: restircting rows

From
Michael Glaesemann
Date:
On Feb 22, 2006, at 18:06 , padmanabha konkodi wrote:
> my query return 100 rows but if i am intrested only from 40-60 rows  
> then how to restrict.
>
> for example
>
> select * from students (returns 100 rows).but i am intrested only  
> rows from 40 to 60.

See LIMIT and OFFSET.
http://www.postgresql.org/docs/8.1/interactive/sql-select.html#SQL-LIMIT

Michael Glaesemann
grzm myrealbox com