Subject | What is wrong with this delete SQL? |
---|---|
Author | Bart Smissaert |
Post date | 2012-08-19T13:13:38Z |
Firebird 1.5, classic on Windows.
Have a table with this structure:
CREATE TABLE KEYWORD(
TERM_KEY CHAR(10) NOT NULL,
TERM_ID CHAR(5) NOT NULL)
There are non-unique indexes on both fields and there are duplicate records.
Now I am trying to run a SQL to delete duplicate records:
delete from keyword k where
not k.rdb$db_key in (select
max(k2.rdb$db_key)
from
keyword k2
group by
k2.term_key,
k2.term_id)
It runs, but no duplicate records are deleted.
The select statement in the above is fine, so it correctly produces
unique records.
Why does the delete SQL not work?
RBS
Have a table with this structure:
CREATE TABLE KEYWORD(
TERM_KEY CHAR(10) NOT NULL,
TERM_ID CHAR(5) NOT NULL)
There are non-unique indexes on both fields and there are duplicate records.
Now I am trying to run a SQL to delete duplicate records:
delete from keyword k where
not k.rdb$db_key in (select
max(k2.rdb$db_key)
from
keyword k2
group by
k2.term_key,
k2.term_id)
It runs, but no duplicate records are deleted.
The select statement in the above is fine, so it correctly produces
unique records.
Why does the delete SQL not work?
RBS