Subject | Re: delete and skip |
---|---|
Author | Milan Babuskov |
Post date | 2007-09-26T11:24:24Z |
---Dalton Calford wrote:
delete from foo f1
where exists (
SELECT 1 FROM foo t2
WHERE t1.foobar = t2.foobar
AND t1.RDB$DB_KEY < t2.RDB$DB_KEY
);
Example adapted from:
http://www.firebirdfaq.org/faq301
--
Milan Babuskov
http://www.guacosoft.com
> delete from foo where foobar='mystuff' skip 1You can use DB$KEY. For example, to delete duplicated foobars:
> to delete duplicate records, leaving only one remaining....
delete from foo f1
where exists (
SELECT 1 FROM foo t2
WHERE t1.foobar = t2.foobar
AND t1.RDB$DB_KEY < t2.RDB$DB_KEY
);
Example adapted from:
http://www.firebirdfaq.org/faq301
--
Milan Babuskov
http://www.guacosoft.com