Jump to content


Photo

Multiple condition with Full text search


  • Please log in to reply
2 replies to this topic

#1 slkhlaw

slkhlaw
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 November 2005 - 04:49 PM

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')?

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 23 November 2005 - 06:43 AM

[!--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'

#3 slkhlaw

slkhlaw
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 November 2005 - 10:26 AM

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) View Post[/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'
[/quote]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users