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
https://forums.phpfreaks.com/topic/2915-multiple-condition-with-full-text-search/
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'

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'

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.