I realise that it would be a lot easier if I could modify the table when it was created, but assuming I can\'t, I have a table that is such as:
abcd
abde
abd
Try this:
SELECT col1, col2 -- etc...
FROM your_table
WHERE 'abffagpokejfkjs' LIKE CONCAT(value, '%')
Note that this will not use an index effectively so it will be slow if you have a lot of records.
Also note that some characters in value
(e.g. %
) may be interpreted by LIKE as having a special meaning, which may undesirable.
LIKE
can be avoided, by truncating the comparison string to each value's length:
... WHERE LEFT('abffagpokejfkjs', LENGTH(value)) = value