hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : MySQL word search
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

MySQL word search

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-07-2002, 02:58 AM
dommymedia dommymedia is offline
New Member
 
Join Date: Sep 2002
Posts: 2

MySQL word search


Climbing the mySQL learning curve, need a hand.

I have a field with Company names, say 1-6 words. What is the best way to set up a multiple keyword query (assume AND search) to do a word search on company names? e.g. searching on "Ford Motor" should match "Ford Motor Company" but not "Waterford Motoring Mills"

Reply With Quote


Sponsored Links
  #2  
Old 09-07-2002, 07:07 AM
bill_jpn bill_jpn is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
Do you also want "Ford Motor" to find such things as "Fordham Motoring" and "Motorboats by Fordham"? If so, one way to do it is,

$xArray = explode(" ", $search);
foreach($xArray as $key=>$value)
{
$searchWhere .= " (MySQL_Field like '$value%'
or MySQL_Field like '% $value')
and ";
}
// finish the final "and"
$searchWhere .= " MySQL_Field != ''";
// Make the query
$query = "SELECT * from TABLE where $searchWhere ";
// etc.

It's best of course to also clean the data; each term should be stripped of HTML and other code, and quotes and so on should be stripped. The foreach will fail if there's an empty $search so that's got to be tested too.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Google+ Business Pages – Implications for Search Marketing Blog 2012-01-25 09:58:46
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Parallels Now Offering Licenses for CloudLinux OS Web Hosting News 2011-10-26 17:29:25
Web Host myhosting.com Offers Free Ad Credits for Bing and Yahoo! Web Hosting News 2011-10-06 18:49:41
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?