advanced search with mysql

Posted by Arsenal on Stack Overflow See other posts from Stack Overflow or by Arsenal
Published on 2010-05-13T10:00:37Z Indexed on 2010/05/13 10:04 UTC
Read the original article Hit count: 187

Filed under:
|
|

I'm creating a search function for my website where the user can put in anything he likes in a textfield. It get's matched against anything (name, title, job, car brand, ... you name it)

I initially wrote the query with an INNER JOIN on every table that needed to be searched.

SELECT column1, column2, ... FROM person INNER JOIN person_car ON ... INNER JOIN car ...

This ended up in a query with 6 or 8 INNER JOINs, and a whole lot WHERE ... LIKE '%searchvalue%'

Now this query seems to cause a time'out in MySql, and I even got a warning from my hosting provider that the queries just taking up too many resources.

Now obviously I'm doing this very wrong, but I was wondering how the correct approach to these kind of search functions is.

Thanks!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php