I have a Products Table, An Orders Table and , An Order Details Table

In the products Table:

|ProductID|ProductType|
|100 |Item One |
|200 |Item Two |

In The orders table:

|OrderID|CustomerID|OrderType |
|123456 |1 | [combined rows]

In the order details table:

|OrderID|ProductID|
|123456|100 |
|123456|200 |

In the orders table, for Order Type, I want the products displayed for order 123456 to combine into one like this:
|OrderType |
|ItemOne,ItemTwo|

When I run this MySQL code:

SELECT orderid, GROUP_CONCAT(productID SEPARATOR ', ') productid from orderdetails

I get this: which is closer to solution, but I want to get the actual product names

|orderid|productid|
|123456 |100,200|

I need to find the solution for the above and I need to add it to my existing query I have:

select * from customers join orders on customers.customerid = orders.customerid

so for my order type, I need to get the combine product names

    So you want to join the products table to the orderdetails table on their ProductID columns, and (if you want to do this part in the database instead of in the application) group concat the ProductType (if that's what you mean by product name)?

      I want to combine the items purchased for order 123456 and place the value into the order type column inside the order table

      Order# 123456

      |Ordertype |
      |ItemOne,Item Two

      Its like I trying to do a JOIN and CONCAT

      You see In the order details table, the person purchased two items under order 123456

      [Order Details Table]

      (Remember --- Item 100 = ItemOne , Item 200 = ItemTwo)

      |OrderID| Productid|

      123456 |100
      123456 |200

      Combine this into ONE

      [Orders Table]

      Order ID| Order Type|
      123456 |ItemOne(100) ,ItemTwo(200)

        Write a Reply...