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