How to delist subset strings if it is a substring of another string I have a list of strings in my database let say in a column

understand
understan
understa
underst
unders
under


I'm trying to find out How to delist subset strings if it is a substring of another string with sql?

So I if we pretend that this is a column of my table, the end result must be only

understand
If you want to delete all records except shown then try something similar to

DELETE dataset.table t1
WHERE EXISTS ( SELECT 1
               FROM dataset.table t2
               WHERE t2.word LIKE CONCAT(t1.word, '_%') )


If you want to select only shown record use

SELECT *
FROM dataset.table t1
WHERE NOT EXISTS ( SELECT 1
                   FROM dataset.table t2
                   WHERE t2.word LIKE CONCAT(t1.word, '_%') )