Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select similar records from mysql database with php?

I have a search form and I would like to select similar items from database based on the searched title.

Now I use SELECT * FROM movies WHERE title LIKE '%".$_SESSION['search']."%';

But e.g. someone search for 'Jurassic Park2' or 'Jurasic Park 2' it doesn't give 'Jurassic Park 2'.

How can I select those movies which has some character difference against the searced title?

like image 343
Makó BestBytePlus Avatar asked Feb 02 '26 02:02

Makó BestBytePlus


1 Answers

You're looking for Mysql full text search. Here's a tutorial to get started. Basically you need to create a fulltext index on the field(s) you want to search, then you can use a query to look up similar values: MATCH (col1,col2,...) AGAINST (expr [search_modifier])


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!