Saya sudah bermain dan saya bisa memberi Anda setengah solusi di mysql murni.
Anda bisa mendapatkan string di kedua sisi kata yang Anda gunakan setelah menggunakan ini. Hanya tidak tahu bagaimana mendapatkan kata daripada seluruh substring. Semoga bermanfaat.
select case when (select w.t regexp concat('[[:<:]]', w.v)) = 1
then substr(w.t, 1, locate(w.v, w.t)-1) else null end as 'left_word',
w.v as word,
case when (select w.t regexp concat(w.v, '[[:>:]]')) = 1
then substr(w.t, locate(w.v, w.t)+length(w.v)) else null end as 'right_word'
from (
select "Lorem ipsum dolor sit amet consectetur adipiscing elit." as t, "amet" as v
) as w;
select case when (select w.t regexp concat('[[:<:]]', w.v)) = 1
then substr(w.t, 1, locate(w.v, w.t)-1) else null end as 'left_word',
w.v as word,
case when (select w.t regexp concat(w.v, '[[:>:]]')) = 1
then substr(w.t, locate(w.v, w.t)+length(w.v)) else null end as 'right_word'
from (
select "Lorem ipsum dolor sit amet consectetur adipiscing elit." as t, "elit." as v
) as w;