Reputation: 4220
I have several strings defined in a php script:
<?php
$array = [
'foobar',
'helloworld',
'applebanana'
];
?>
From those strings I've generated several substrings and put them into a database:
+-------------+---+
| id | substrings |
+----+------------+
| 1 | bar |
| 2 | world |
| 3 | banana |
+----+------------+
I can't say how long each string/substring will be and I cannot use a delimiter. But I can say that the substring is always positioned to the very most right of the original.
So what I'd like to know is, how can I use the longer strings to find the shorter substrings of it in the database?
Note: I can't really use substring() or right() because I don't know the length of the substring in the database.
Upvotes: 0
Views: 225
Reputation: 3749
Given any string you have, you can still use right
in conjunction with lenght
:
select * from substr_table where right('foobar', length(substrings)) = substrings
However, this sounds like a terrible application design.
Upvotes: 2