PDA

View Full Version : muiltple MySQL joins form checkbox array



deletedUser2352352
September 9th, 2007, 07:52 AM
Hello all hope your all well.

I hope someone can help me work this out.


I have a database set up that has recipes and food requirements.

Each recipe can have more then one food requirement.

eg:

Sweet Chicken Curry may contain: Nuts, Milk etc etc

The tables are set up like this

cms_recipe
recipe_id
recipe_ingrediants
recipe_method

cms_dietary
dietary_id
dietary_name

cms_recipe_dietary
recipe_id
dietary_id

How can i construct a query that loops through a checkbox array and brings back all the recipes that don't have the dietary requirements in them.

i reakon it would use joins and such but have no idea what the best way to do this or the least clumsy

Please note that the dietary table can be added to at later date.

Hope that makes sense.

ps mind my spelling i'm working on a tablet pc and haven't fully got comfortable with it.

:)

deletedUser2352352
September 9th, 2007, 12:53 PM
anyone?

This has really stumped me.

deletedUser2352352
September 9th, 2007, 02:31 PM
This is what i have so far but how do i add in the dietary requirements process?


SELECT a. * , b.tin_name
FROM cms_recipes
INNER JOIN cms_tin b ON a.tin_id = b.tin_id
WHERE a.tin_id =1
AND a.recipe_ingredients LIKE '%2%

deletedUser2352352
September 11th, 2007, 07:29 AM
please can anyone help me with this?

Its looking grim. help

eirche
September 11th, 2007, 09:41 PM
all the recipes that don't have the dietary requirements in them.

what do you mean by that? the recipes that are not in cms_recipe_dietary?