943,807 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Unsolved
  • Views: 5323
  • ColdFusion RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jun 18th, 2009
0

Re: how to populate a cfselect box depending upon the selection on raido button

thx
Reputation Points: -32
Solved Threads: 3
Light Poster
cartman714 is offline Offline
43 posts
since Jun 2009
Jul 23rd, 2009
0

Re: how to populate a cfselect box depending upon the selection on raido button

Click to Expand / Collapse  Quote originally posted by nagkar ...
Thanks the given sql is working ...it gave me correct data ..but now the problem is that it is displaying same data multipile times.i.e




ingredient........lotids............d_amount.......d_unit


xyz...............5t6y
xyz................7yh8
xyz................98uj


uvw.................9jnu


instead of that i need to display it as



xyz...............5t6y
..................7yh8
...................98uj


uvw.................9jnu
You are going to have to control the grouping of the xyz data by either testing for changes in some control variable assigned that value, or using built-in's of whatever flavor of sql your are using.
For instance, if your using mySql you could use group_concat
something like:
select table.*, GROUP_CONCAT(concat('Lot:',lotids,'Amt:',d_amount,'unit:',d_unit),'||') as big_lots
from table
left outer join ....
where ....
group by ingredient
having (table.whateverfield like 'whatever')

that give you one row per ingredient with a field called big_lots aggregating all the lots into it, delimited by || which you have to parse it out of to display nicely etc.. Anyway, it's an idea for which there are lots of solutions..

Bob
Reputation Points: 12
Solved Threads: 1
Newbie Poster
macslayer is offline Offline
11 posts
since Mar 2008
Jul 24th, 2009
0

Re: how to populate a cfselect box depending upon the selection on raido button

in the sql, try replacing "inner join" (which will return all matching rows from both tables) to "LEFT OUTER JOIN" which will essentially focus on the 1st table.

The problem, really might be that you have a "Many to Many" relationship in the DB. If the Recipe table links to the Lot table on ingredient and there are multiply rows for the same ingredient in both tables, your tables will never join properly. The solution is for the Recipe table to refer to a unique id in the lot table or add a table or two for better "normalization".

Assuming you are storing Products, Recipes, Ingredients and Lots, this is a possible schema:

tblProduct
  • productID (PK)
  • productName

tblRecipe
  • recipeID (PK)
  • productID (refers to tblProduct.productID)
  • ingredientID (refers to tblIngredient.ingredientID)
  • quantity

tblIngredient
  • ingredientID (PK)
  • ingredientName
  • lotID (refers to tblLot.lotID)
  • unit

tblLot
  • lotID (PK)
  • lotNumber

Then you could query one recipe with this SQL:
sql Syntax (Toggle Plain Text)
  1. SELECT r.quantity, i.ingredientName, i.unit, l.lotNumber
  2. FROM tblProduct p LEFT OUTER JOIN
  3. tblRecipe r ON r.productID = p.productID LEFT OUTER JOIN
  4. tblIngredient i ON i.ingredientID = r.ingredientID LEFT OUTER JOIN
  5. tblLot l on l.lotID = i.lotID
  6. WHERE p.productID = **some_product_id**
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gklandes is offline Offline
10 posts
since Jul 2009
Jul 24th, 2009
0

Re: how to populate a cfselect box depending upon the selection on raido button

I think his sql is working perfectly, as I read is that he is having a presentation issue, not relationship issue. His relationship looks like a one-to-many on ingredients to lots. He just does not know how to handle the repeating left hand column data joined to the right hand. So, he was looking for methods to not repeat the ingredient on the 1+nth lot. Anyway, that is how I read it.
Reputation Points: 12
Solved Threads: 1
Newbie Poster
macslayer is offline Offline
11 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: Has anybody tried the new Adobe Coldfusion?
Next Thread in ColdFusion Forum Timeline: How to access cfdocument.currentpagenumber outside the cfdocumentitem tag





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC