webguync Posted January 24, 2012 Share Posted January 24, 2012 I am working on Query application which returns results from a MySQL DB. The database consist of players from various sports teams, and list their name, city, sport, etc. The issue is if you type in a search terms from one of the fields any result will return and I only want unique results. For instance if you type in 'New York Giants', you will get a return of all the New York teams, even though I have city and team name in two different columns. The Query is matching 'New York and returning all results with that in the Query. Anyway here is my SQL code. SELECT sport,first_name,last_name,MVP,city,Picture,team FROM players WHERE MATCH(sport,first_name,last_name,MVP,city,team,Picture) AGAINST('$query' IN BOOLEAN MODE)"); Quote Link to comment https://forums.phpfreaks.com/topic/255635-need-help-refining-a-query/ Share on other sites More sharing options...
fenway Posted January 24, 2012 Share Posted January 24, 2012 What did you expect? You have a FULLTEXT index on multiple columns. You're asking MySQL to decide which words matter. Of course, you could have searched the "phrase". Quote Link to comment https://forums.phpfreaks.com/topic/255635-need-help-refining-a-query/#findComment-1310680 Share on other sites More sharing options...
webguync Posted January 24, 2012 Author Share Posted January 24, 2012 can you provide an example of the SQL for searching a Phrase? Quote Link to comment https://forums.phpfreaks.com/topic/255635-need-help-refining-a-query/#findComment-1310686 Share on other sites More sharing options...
fenway Posted January 24, 2012 Share Posted January 24, 2012 The mysql refman has all of the syntax for MATCH... AGAINST()... but it should just be quoted. Quote Link to comment https://forums.phpfreaks.com/topic/255635-need-help-refining-a-query/#findComment-1310719 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.