Karim
Karim

Reputation: 434

How do i perform a search in mysql with a substring, instead of full string?

How do i perform a search in mysql with a substring, instead of full string ?

i would like to return information from a search term e.g.. 'Wat' will return Waterloo and any other words with Wat in them ..

Upvotes: 1

Views: 96

Answers (2)

senseiwu
senseiwu

Reputation: 5279

You can use like '%Wat%', but if you want more sophisticated conditions, you may consider using rlike which leverages regular expressions

Upvotes: 1

Filipe Silva
Filipe Silva

Reputation: 21677

You can do it with a like:

SELECT * FROM YOUR_TABLE
WHERE YOURCOLUMN LIKE '%Wat%';

If you are only looking for something starting with Wat you can drop the first %

Upvotes: 2

Related Questions