We can use MySQL built-in functions INSTR
To find whether a string contains another substring. INSTR
The function returns the first occurrence position of the specified substring in the original string. If it is not found, it returns 0.
The following is the use of INSTR
Function to find a string (for example test_string
)Does it contain a specific character (for example a
)Sample query for:
SELECT INSTR (test_string, 'a' ) FROM your_table;
If test_string
Contains characters in a
, the query will return test_string
First occurrence of character in a
Location of; Otherwise, it will return 0.
If you want to check whether there are multiple characters, you can use multiple INSTR
Function, or use regular expressions in queries.