0

I am working on site search engine i am able to do searches, now i want to modify query so as to make a smart search.

I am writing my query like this

    require_once('../global/connect.php');
$db = mysql_select_db($database,$connection) or trigger_error("SQL", E_USER_ERROR);
$sqlquery = mysql_query("SELECT title FROM test_table WHERE MATCH (title) AGAINST ('%keyword*%' IN BOOLEAN MODE) ")or die (mysql_error());
while($row=mysql_fetch_assoc($sqlquery)){
echo $row['title'];
echo"</br>";
}

I want a search functionallity that can search like.

if user type any of these keywords

KEYWORDS
KEY-WORDS
KEY-WORDS
KEY WORDS
KEYWORD
KEYWOR

result should be same.

I have looked around many question here like this. and goggled it, also looked at MySQL developer website here, but i cant get any idea how to modify my query to get it work.

Please suggest any possible approach to this.

Thanks.

Community
  • 1
  • 1

2 Answers2

0

Try SOUNDS LIKE:

SELECT title FROM test_table WHERE title SOUNDS LIKE '%keyword*%'
Ayman Safadi
  • 11,502
  • 1
  • 27
  • 41
0

I'd recommend using Lucene for doing searches. It supports fuzzy matching. Also, you'll have less load on your database.

Eamorr
  • 9,872
  • 34
  • 125
  • 209