From: | "Andy Shellam" <andy(dot)shellam(at)mailnetwork(dot)co(dot)uk> |
---|---|
To: | "'sandhya'" <sandhyar(at)amiindia(dot)co(dot)in> |
Cc: | <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: reg:Query |
Date: | 2006-05-16 13:28:11 |
Message-ID: | !~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAAC4AAAAAAAAAt+qV6pqKPEmXG74TlFgX5gEAlpDSN+DrMEWnumhoRHpQKQAAAbLc9wAAEAAAAD/QYCgegltIpPug7EE8rRQBAAAAAA==@mailnetwork.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Depends on which version of Postgres youre using (pre-8.0 or post-8.0)
I think the format changed from v8.0 onwards. So, for example, post-8.0:
SELECT email_address FROM account_details ORDER BY address_id LIMIT 1
OFFSET 0;
Will bring back the first row. The following will bring back the next and
so on:
SELECT email_address FROM account_details ORDER BY address_id LIMIT
1 OFFSET 1;
Pre-8.0 the queries would be:
SELECT email_address FROM account_details ORDER BY address_id LIMIT
1, 0;
SELECT email_address FROM account_details ORDER BY address_id LIMIT
1, 1;
Note LIMIT 1, 0 (and LIMIT 1 OFFSET 0) is the same as LIMIT 1
Andy
________________________________________
From: sandhya [mailto:sandhyar(at)amiindia(dot)co(dot)in]
Sent: 16 May 2006 2:28 pm
To: andy(dot)shellam(at)mailnetwork(dot)co(dot)uk
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] reg:Query
yes..I got it.
SELECT .................... LIMIT x OFFSET y.Am i right?
----- Original Message -----
From: Andy Shellam
To: 'sandhya'
Cc: pgsql-admin(at)postgresql(dot)org
Sent: Tuesday, May 16, 2006 6:35 PM
Subject: FW: [ADMIN] reg:Query
Actually, just realized, this depends on your PGSQL version.
The older format (pre-8.0 I believe) is SELECT
.. LIMIT x, y (where x is
the number of rows to fetch, and y is the offset (ie. Select x number of
rows, starting from row y.)
Andy
________________________________________
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Andy Shellam
Sent: 16 May 2006 1:57 pm
To: 'sandhya'
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] reg:Query
SELECT .. LIMIT 1
Will get the first row in the dataset. Then to fetch the next row, you can
do SELECT
LIMIT 1 OFFSET 1 (will get the 2nd record) and so on.
(replace
.. with your conditions, LIMIT must come at the end of the query)
Andy
________________________________________
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of sandhya
Sent: 16 May 2006 11:47 am
To: Postgres
Cc: sandhya
Subject: [ADMIN] reg:Query
Hi
Is there any query for possibility of getting only one row at a time in a
group of records?
With distinct rows & Columns my query has to return only one record at a
time with out any condition.Will it be possible?
Thank you,
Sandhya
!DSPAM:14,4469d1a234495652214946!
From | Date | Subject | |
---|---|---|---|
Next Message | sandhya | 2006-05-16 13:28:28 | Re: reg:Query |
Previous Message | Kouber Saparev | 2006-05-16 13:16:55 | Updatable view and default sequence values |