TitusRevised Posted July 24, 2006 Share Posted July 24, 2006 Is there an sql function to SELECT any rows in a table most similar to a field... like instead of SELECT * FROM table WHERE field LIKE '%$string%' which finds a row with keyword $string, so if $string is "hi my name is" but there isnt a row like but there is a row "hello my name is" it would pull that row because its most similar.PHP example:<?php$string = trim(strip_tags(addslashes($_POST['usermsg'])));$sql = mysql_query("SELECT * FROM table WHERE field = '%$string%");// This finds me a row where field "field" has the $string in it exactly somewhere?>How can I make it so that if it's not exact it pulls out the row with the field "field" most similar to $string?Your great wisdom and intelligence on the matter to assist me is appreciated greatly. Quote Link to comment Share on other sites More sharing options...
hvle Posted July 24, 2006 Share Posted July 24, 2006 is this a text search? Quote Link to comment Share on other sites More sharing options...
TitusRevised Posted July 24, 2006 Author Share Posted July 24, 2006 [quote author=hvle link=topic=101617.msg402305#msg402305 date=1153710195]is this a text search?[/quote]yes, $string is a string...text Quote Link to comment Share on other sites More sharing options...
hvle Posted July 24, 2006 Share Posted July 24, 2006 you might want to look at "match .. against()" in mysql manual Quote Link to comment Share on other sites More sharing options...
448191 Posted July 24, 2006 Share Posted July 24, 2006 Yes, you can use full-text searching. If, this is manditory, you're able to add a fulltext index on the column you want to search. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.