Jump to content

Explode Question


wemustdesign

Recommended Posts

Hi,

 

I have a database that is going to contain recepies and ingredients tables. The recipe table is going to store the ingredients like this:

 

1,5,6,8

 

This refers to the table ingredients id.

 

I now want to explode these vaules and count them up so they can be outputted like this:

 

sugar (2)

honey(1)

flour (3)

 

I have no idea of how to count all of the exploded id's and ouput them like above

Link to comment
Share on other sites

I think u should give thought about the design of the db before making a db that becomes inflexible later on.

there is no need to store all the recipes ingredients in the same table, if u design your db for flexibility in for the long run.

as most of what your asking SQL can already handle

 

 

 

Recipe Table:

id

Name

Description

Instructions

 

Ingredients

id

Name

 

RecipeIngredients

RecipeId

IngredientID

Amount

 

with those 3 tables, I can do exactly wut u need all within sql

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.