UnknownPlayer Posted January 25, 2011 Share Posted January 25, 2011 I need help with search form. When someone enter in search form "dota allstars", if in mysql is no such a thing like that at table "news", i wonna to find similar data, how can i do that? Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted January 25, 2011 Share Posted January 25, 2011 I need help with search form. When someone enter in search form "dota allstars", if in mysql is no such a thing like that at table "news", i wonna to find similar data, how can i do that? What do you consider "similar data"? Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted January 25, 2011 Author Share Posted January 25, 2011 Something like "dota" then "allstars" I just need to know how other search engines work :S Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted January 25, 2011 Share Posted January 25, 2011 Something like "dota" then "allstars" I just need to know how other search engines work :S You can use LIKE and the wildcard % or better would be full-text searching: http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted January 25, 2011 Author Share Posted January 25, 2011 Can u give me example of full-text searching please ? Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted January 25, 2011 Share Posted January 25, 2011 Can u give me example of full-text searching please ? Look at the link I posted. There are examples all in there. You have to set the fields as FULLTEXT in the table definition: CREATE TABLE articles ( -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, -> title VARCHAR(200), -> body TEXT, -> FULLTEXT (title,body) -> ) ENGINE=MyISAM; Then something like: SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('dota allstars') 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.