Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

(click on this box to dismiss)

What SQL statement can I use for contains?

I want to select all the rows that contain a substring, how can I do this fast? I have an index on the column that I'm testing.

link comment (0)
asked 6 years ago
9 Answers

How about using LOCATE or POSITION functions?

SELECT * from my_table
WHERE LOCATE('phrase', title) > 0;

0 is returned if the title column does not contain the phrase.

I should also mention that these functions are case-sensitive. See the manual for more information

link comment (0)
answered 6 years ago

You are either using a very old browser or a browser that is not supported.
In order to browse you need to have one of the following browsers:

Internet Explorer: Mozilla Firefox: Google Chrome: