0

I was wondering....is it possible to retrieve a value from a mysql database if the value of the WHERE statement is similar to the input text? Something like the similar_text() function but applied to the search condition.

Example:

 <?php
   $res = mysqli_query(*CONECTION*,"SELECT value FROM table WHERE condition=*is similar to x*");
  ?>

If this thing is possible please tell me how.

SpiderLinked
  • 363
  • 1
  • 6
  • 14
  • Use [`LIKE`](http://beginner-sql-tutorial.com/sql-like-in-operators.htm) --- [`full-text indexes`](http://www.tuxradar.com/practicalphp/9/3/18) could also be an option. – Funk Forty Niner Nov 02 '13 at 16:32

2 Answers2

0

You need make use of the LIKE keyword

SELECT value FROM table WHERE condition like %x%

EDIT :

Seems like you are for levenshtein algorithm. Have a look here and here.
StackOverflow Thread

Community
  • 1
  • 1
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0
SELECT value, MATCH(value) AGAINST('x' IN BOOLEAN MODE) AS similarIndex
FROM table WHERE MATCH(value) AGAINST ('x' IN BOOLEAN MODE) 
ORDER BY similarIndex DESC