[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

SQL help for a brainy person... Can someone please help me with asome AOH in perl & MySQL

Asked by timbo007 in Perl Programming Language, Databases Miscellaneous, MySQL Server

Tags: mySQL, SQL, Perl

Hello, my question is hard to explain but I will do my best,

I am using Perl/MySQL to make a shopping cart system and have a very specific requirement for displaying items.

I have managed to write (and rewrite) a good deal of SQL to get me the values from the database looking the way I want. The next step is to get them into a data structure that I can then send to my template (I'm using HTML::Template)

The best way I can explain myself is through example so here goes..

I want to end up with a data structure looking something like in the code I made up below but the results are to come from the MySQL database which are also in the code below with the SQL statement to produce it, I just need the Perl part to turn it into the other.

In Perl I would be going through the rows one at a time, but am stuck at turning it into the AOH or whatever I need...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
#This is my SQL which produces the result below which is great...
 
SELECT pi.product_name product_name, product_specs.product_ID, product_specs.p_comp, product_specs.p_s_comp, product_specs.price
FROM product_specs
LEFT JOIN product_item pi ON pi.ID = product_specs.product_ID
WHERE product_specs.product_ID =3
AND product_specs.show_on_website != '1'
AND product_specs.live = '1'
ORDER BY product_specs.p_comp ASC , product_specs.price ASC;
 
 
# the result:
 
 
ID 	product_name 	product_ID 	p_comp 			p_s_comp 	price 
18	BPB Aquastop	3		Sheet Size 1200 x 10mm	x 2400mm l	29.9
19	BPB Aquastop	3		Sheet Size 1200 x 10mm	x 2700mm l	33.9
20	BPB Aquastop	3		Sheet Size 1200 x 10mm	x 3000mm l	36.9
21	BPB Aquastop	3		Sheet Size 1200 x 10mm	x 3600mm l	43.9
22	BPB Aquastop	3		Sheet Size 1200 x 13mm	x 2400mm l	36.9
23	BPB Aquastop	3		Sheet Size 1200 x 13mm	x 2700mm l	41.4
24	BPB Aquastop	3		Sheet Size 1200 x 13mm	x 3000mm l	45.9
 
# each product would sit in my data structure like so:
# this is where it gets hard - there is only 2 real products in this result, they are split by the p_comp column, then there is different 
# lengths of each of those 2 products which also have different prices, this is the p_s_comp and price fields which can easily be 
# joined as one column... the end result is in the website, there will be 2 items ina  table displayed and each item has a drop down 
# list which shows the different lengths/prices. So I figured if I could get this data into a data structure like below, then I would be 
# in business ;) make sense?
 
# also the result needs to be in price order of lowest to highest in each of the sub components, if I use a hash it may not work so array to keep the order could be better, but below I have used a hash...
 
#(note the hash in the sub_components part below...) 
# also I don't really know how to have multiple anonymous hashes or arrays, I just guessed it would be like $products = { ... } { ... } { ... };
 
$products = {
  ID=> 3,
  name=> BPB Aquastop,
  component=> Sheet Size 1200 x 10mm,#this is actually what groups them together - if these are the same then it should be in the same group or product which will end up in the right drop down list...
  sub_components=> {18=>"x 2400mm l 29.9", 19=>"x 2700mm l 33.9", 20=>"x 3000mm l 36.9", 21=>"x 3600mm l 43.9"},
} { 
  ID=> 3,
  name= BPB Aquastop,
  component=> Sheet Size 1200 x 13mm, 
  sub_components=> {22=>"x 2400mm l 36.9", 23=>"x 2700mm l 41.4", 24=>"x 3000mm l 45.9"}, # this structure needs to have the order remain intact so should be an array somehow.. I'd prefer not to use a hash tie method to order the hash...
}
 
Related Solutions
Keywords: SQL help for a brainy person... Ca…
 
Loading Advertisement...
 
[+][-]10/22/09 07:56 AM, ID: 25634974Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/09 08:14 AM, ID: 25635168Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/22/09 08:37 AM, ID: 25635452Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/09 08:43 AM, ID: 25635538Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Perl Programming Language, Databases Miscellaneous, MySQL Server
Tags: mySQL, SQL, Perl
Sign Up Now!
Solution Provided By: Adam314
Participating Experts: 1
Solution Grade: A
 
[+][-]10/22/09 09:13 AM, ID: 25635874Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/09 09:18 AM, ID: 25635922Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/09 09:47 AM, ID: 25636228Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/09 09:58 AM, ID: 25636360Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625