Re: Re: how to do a search in mysql database for multiple keywords??

From: Date: Mon, 15 Oct 2001 11:37:37 +0000
Subject: Re: Re: how to do a search in mysql database for multiple keywords??
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-71093@lists.php.net to get a copy of this message
Another solution would also be to use the FULLTEXT functions availble in MySQL... it is by far faster than this query. To do so, your fields must be of type VARCHAR and TEXT. Then create a FULLTEXT index on these fields by issuing the following command: ALTER TABLE <tablename> ADD FULLTEXT(<column1>,<column2>,<ccolumn3>) Then your query would look like: SELECT *, MATCH(<field1>,<field2>,<field3> ) AGAINST ('$qiery' ) AS score FROM Messages WHERE MATCH( <field1>,<field2>,<field3> ) AGAINST ( '$query' ) ORDER BY score DESC; This would return the results in order of relevance... works pretty good :) -- ------------------------------------------------------------------------ James "Mike" Patton \ Professional web applications developer mpatton@acuitymedia.com \ Specializing in PERL, MySQL, PHP and JAVA ------------------------------------------------------------------------ On 2001.10.15 03:42 _lallous wrote: > describe your question more... > anyway: > > SELECT thetext FROM thetable WHERE > (INSTR(thetext, 'keyword1') <> 0) OR > (INSTR(thetext, 'keyword2') <> 0) OR > (INSTR(thetext, 'keyword3') <> 0); > > this will search for either of the three keywords... > > "Nicklas Bondesson" <nicke@najki.nu> wrote in message > news:20011013133802.49776.qmail@pb1.pair.com... > > need some help on this. i've come so far that i have split up the > variable > > with explode and putting it into an array that looks like this: > > 'keyword1','keyword2'. > > > > but it doesn't doesn't work satisfactory... > > > > any ideas?? > > > > /nicke > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#71093) next »