How can I return all entries in a table that contain a string in a given column if the same string is also present in the same column with a given suffix ?
So for example, given the suffix ‘bar’, and the following table:
x
id A
1 foo1
2 foo2
3 foo1bar
I want to return the the first entry, because there’s another entry (the third one) which has the same value when the suffix is appended.
Advertisement
Answer
SELECT t1.*
FROM table t1
JOIN table t2 ON CONCAT(t1.column, 'bar') = t2.column