Jump to content

Archived

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

bcamp1973

*SOLVED* ignoring non-unique results on SELECT statements

Recommended Posts

when i do the following SELECT statement it's possible for the recipe to be returned multiple times if an ingredient applies more than once...such as a search on "garlic" that may return on "garlic", "garlic cloves", "garlic salt" etc.  How can i limit the select so it only returns one instance of the recipe even on multiple ingredient matches?

[code]
SELECT
   recipes.name,
   recipes.description
FROM
   recipes, recipe_ingredients
WHERE
   recipe_ingredients.recipe_id=recipes.id
AND MATCH(ingredient) AGAINST ("'.strtolower($_GET['ingredient']).'" IN BOOLEAN MODE)
ORDER BY name ASC
[/code]

Share this post


Link to post
Share on other sites
Add a "GROUP BY recipes.id"

Share this post


Link to post
Share on other sites
awesome!  thank you...i didn't even think to look at the GROUP BY function as I was making my way through the function list.  Cheers!

Share this post


Link to post
Share on other sites

×

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.