Jump to content

Need Help With Search Query


arandlett

Recommended Posts

I have built a search query. However doesn't seem to be working like I need it. I can search by just typing one word that will match one column however if I add multiple words the search will not work. I didn't think full text searching would work because the columns that I am searching do not have a lot text. At the most a sentance of text. Should I still use Full Text searching & how do I do that? Or can something be done in the query below to solve my problem.


[code]SELECT *
FROM Members
WHERE `First` LIKE %colname% OR `Last` LIKE %cname1% OR `City` LIKE %cname2% OR `dac` LIKE %cname3% OR `dnc` LIKE %cname4% OR `min_teams` LIKE %cname5% OR `Industry` LIKE %cname6% OR `status` LIKE %cname7%[/code]
Link to comment
Share on other sites

Ok I set a fulltext index in the table with two columns "First, Last" for testing.  Second I changed the sql query to read :

[b]SELECT *, MATCH (First,Last) AGAINST ('$searchKey') FROM Members[/b]

However when I go to test it I get the same results.  Where I can only search by one word and not to.  So I can either type in a "First" word or a "Last" word to pull any results.  When I type " First  Last " in the keyword field nothing returns. 

Link to comment
Share on other sites

Ok I figured It out however need some wildcard to it.  Right now you can search by multiple words but those words have to exactly like they are minus capitals in the columns.
[b]
SELECT *, MATCH (First,Last,education,Address1,City,Zip,Email,officer,dac,min_teams,status) AGAINST ('$searchKey') FROM Members WHERE  MATCH (First,Last,First,Last,education,Address1,City,Zip,Email,officer,dac,min_teams,status) AGAINST ('$searchKey') AND level <> 3[/b]

How do I change this so that if they type a part of that word or if it is almost like that word it will still pull results. Thank you for all the help.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.