Jump to content

Multiple condition with Full text search


slkhlaw

Recommended Posts

I got a bit lost with full text search using MySQL. I hope someone could help me.

I am trying to search and display id, title, description from a database with additional condition to it.

Could someone help me?

 

SELECT id, title, description from articles where match (title,description) against ('searchstring');

 

Where do I put the additional conditions say, I want it to search for PostedDate > 1/1/2005 and not later than 1/10/2005 and (AuthorRank != 'Noobie' or Author='Peter')?

Link to comment
Share on other sites

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] id, title, description from articles where match (title,description) against ('searchstring') AND PostedDate BETWEEN '2005[span style=\'color:orange\']-01-02'[/span] AND '2005[span style=\'color:orange\']-10-1'[/span] AND (AuthorRank != 'Noobie' or Author='Peter') [!--sql2--][/div][!--sql3--]

You may need to change the last condition depending on what exactly you're looking for. The last condition currently says that you'd like to get results if AuthorRank != 'Noobie', but if Author = 'Peter' you'd still like results even if the AuthorRank is 'Noobie'

Link to comment
Share on other sites

Works like a charm! Thanks.

I substitute "OR" with "XOR" to make sure Peter I meant wasn't a Noobie.

 

Thank you so much.

 

[!--quoteo(post=321336:date=Nov 23 2005, 06:43 AM:name=shoz)--][div class=\'quotetop\']QUOTE(shoz @ Nov 23 2005, 06:43 AM) 321336[/snapback][/div][div class=\'quotemain\'][!--quotec--]

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] id, title, description from articles where match (title,description) against ('searchstring') AND PostedDate BETWEEN '2005[span style=\'color:orange\']-01-02'[/span] AND '2005[span style=\'color:orange\']-10-1'[/span] AND (AuthorRank != 'Noobie' or Author='Peter') [!--sql2--][/div][!--sql3--]

You may need to change the last condition depending on what exactly you're looking for. The last condition currently says that you'd like to get results if AuthorRank != 'Noobie', but if Author = 'Peter' you'd still like results even if the AuthorRank is 'Noobie'

 

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.