V
V
Vladimir Korotenko2020-03-27 11:55:57
MySQL
Vladimir Korotenko, 2020-03-27 11:55:57

Finding a sentence in a text using SQL?

Actually, the task is to isolate the sentence where the search phrase occurs using SQL in my case, MySQL and Sqlite.

For example:

Search field
"This is a test case for search. This sentence contains the search word. This is completely unnecessary."
Search query sentence

Expected result phrase

This sentence contains the search word

That is, the cutoff is roughly speaking for the group of characters ?!. and search expression.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-03-27
@firedragon

SELECT LEFT( Text, LOCATE( 'поиска', Text ) + LENGTH ('поиска') - 1)
  FROM Texts
  WHERE Text LIKE '%поиска%'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question