Re: Deleting in order from a table

From: Ludwig Lim <lud_nowhere_man(at)yahoo(dot)com>
To: pginfo <pginfo(at)t1(dot)unisoftbg(dot)com>
Cc: PostgreSQL Mailing List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Deleting in order from a table
Date: 2003-01-05 12:18:37
Message-ID: 20030105121837.20686.qmail@web80304.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


--- pginfo <pginfo(at)t1(dot)unisoftbg(dot)com> wrote:
> I have a table tableA ( ....,order_num int).
>
> I will to delete some records from tableA but in asc
> or desc
> order_num-order.
>
> Is it possible to write delete from tableA where
> (some conditions) order
> by order_num ?
>
> Many thanks,
> ivan.
>

Try the following:

DELETE
FROM tableA
WHERE order_num IN (
SELECT order_num
FROM tableA
ORDER BY order_num
LIMIT n OFFSET m);

Use LIMIT to determine the number of rows to delete
and OFFSET to determine the "starting row".

ludwig

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Cédric Dufour (public) 2003-01-06 10:12:25 Grant execute on functions; related objects permissions ?
Previous Message Peter Galbavy 2003-01-05 10:41:15 weighting (the results of) a query ?