Home mysql MySQL Search for entering Substring in line

MySQL Search for entering Substring in line

Author

Date

Category

How to make a search on the row in line?

Here is an example, you need to find on the field [STR] entry “A”:

[0] [n] "TABL", [STR] "A, B, C"
 [1] [n] "CATL", [STR] "B, C"

Conclusion:

[0] [n] "TABL", [STR] "A, B, C"

Answer 1, Authority 100%

is not very clear the presentation of the table if n and str are the columns of the table, then enough, as indicated in the comments, use the LIKE operator

select
 *
From.
 TBL
Whater
 STR LIKE '% A%'

If [0] [N] "TABL", [STR] "A, B, C" and [1] [n] "CATL", [STR] " B, C "These are the lines for which the search is carried out, it is better to use regular expressions, i.e. Operator RLIKE

select
 *
From.
 TBL
Whater
 Name Rlike "\ [STR \]. * a. * $"

Answer 2, Authority 25%

Sorry, a person from comments helped, since he does not write that I will write.

select * from tbl where str like '% a%'

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions