slkhlaw Posted November 22, 2005 Share Posted November 22, 2005 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')? Quote Link to comment Share on other sites More sharing options...
shoz Posted November 23, 2005 Share Posted November 23, 2005 [!--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 Link to comment Share on other sites More sharing options...
slkhlaw Posted November 23, 2005 Author Share Posted November 23, 2005 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' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.