[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.2

MySQL Select with a Loop

Asked by sean-keys in Unix Systems Programming, MySQL Server, SQL Query Syntax

Hi I have two tables orders and orders_products.  The code below returns 4 rows, because there are 4 products that have been ordered within 2 orders.  In stead of return the 4 ordered products I need to return the 2 orders with the products details in those results.

ST*850*1005~BEG*00*SA*1005**20090826~N1*BT*Business~N3*4225 TIMMY BLVD STE M~N4*Palo*CA*92056~N1*ST*John Doe~N3*555 TEST St~N4*Test*Arizona*85379~PO1*1006*6*EA**VN*PAR D879514D  ~PID*F****1 LOVE (DVD) (WS)                                               ~CTT*3*****~SE*16*1005~
ST*850*1006~BEG*00*SA*1006**20090826~N1*BT*Business~N3*4225 TIMMY BLVD STE M~N4*Palo*CA*92056~N1*ST*John Doe~N3*555 TEST St~N4*Test*Arizona*85379~PO1*1007*1*EA**VN*ANB D15341D   ~PID*F****10 MINUTE SOLUTION-PRENATAL PILATES (DVD/INCLUDES BODY BAND)    ~CTT*3*****~SE*16*1006~
ST*850*1006~BEG*00*SA*1006**20090826~N1*BT*Business~N3*4225 TIMMY BLVD STE M~N4*Palo*CA*92056~N1*ST*John Doe~N3*555 TEST St~N4*Test*Arizona*85379~PO1*1008*1*EA**VN*ANB D15958D   ~PID*F****10 MINUTE SOLUTION-QUICK TUMMY TONERS (DVD)                     ~CTT*3*****~SE*16*1006~
ST*850*1006~BEG*00*SA*1006**20090826~N1*BT*Business~N3*4225 TIMMY BLVD STE M~N4*Palo*CA*92056~N1*ST*John Doe~N3*555 TEST St~N4*Test*Arizona*85379~PO1*1009*1*EA**VN*ANB D14625D   ~PID*F****10 MINUTE SOLUTION-RAPID RESULTS PILATES (DVD)                  ~CTT*3*****~SE*16*1006~



The last order needs to be combined so that I just get one result with 3 product lines like this one

~PO1*1009*1*EA**VN*ANB D14625D~
PID*F****10 MINUTE SOLUTION-RAPID RESULTS PILATES (DVD)                  

Any help would be greatly appreciated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
SELECT CONCAT( 'ST*850*', o.orders_id, '~',
                                'BEG*00*SA*', op.orders_id, '**', CURDATE( ) +0, '~',
                                 'N1*BT*Business~',
                                 'N3*4225 TIMMY BLVD STE M~',
                                 'N4*Palo*CA*92056~', 
                                 'N1*ST*', o.delivery_name, '~',
                                 'N3*', o.delivery_street_address, '~',
                                 'N4*', o.delivery_city, '*', o.delivery_state, '*', `delivery_postcode` , '~',                            'PO1*', op.orders_products_id, '*', op.products_quantity, '*EA**VN*', op.products_model, '~',
                                 'PID*F****', op.products_name, '~',
                                 'CTT*3*****~',
                                 'SE*16*', o.orders_id, '~' )
FROM orders o
INNER JOIN orders_products op ON op.orders_id = o.orders_id
WHERE o.orders_status =2;
[+][-]08/26/09 02:54 PM, ID: 25192670Author 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.

 
[+][-]08/26/09 03:25 PM, ID: 25192901Expert 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.

 
[+][-]08/26/09 04:04 PM, ID: 25193175Accepted 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: Unix Systems Programming, MySQL Server, SQL Query Syntax
Sign Up Now!
Solution Provided By: cxr
Participating Experts: 2
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625