sql - SQLite - How to remove rows that have a string cell value contained in other rows? -
i have table in sqlite database:
----------------------------- id | string |...other columns ----------------------------- 01 | aa |... 02 | aab |... 03 | ab |... 04 | bab |... what need remove rows cell value of column "string" contained in other row.
in example above, row id-1 string contained in row id-2 string , row id-3 string contained in both row id-2 , id-4 strings.
so final result should be:
----------------------------- id | string |...other columns ----------------------------- 02 | aab |... 04 | bab |... is there easy query perform operation?
you can use exists (case–insensitive):
delete table exists (select * table t t.string '%' || table.string || '%') or instr (case–sensitive):
delete table exists (select * table t instr(t.string, table.string) > 0)
Comments
Post a Comment