Nathan Parrett
Nathan Parrett

Reputation: 157

Possible combinations of same values in mysql table

I am looking to find a way of displaying the following output

**Name**
Red Small
Red Medium
Green Small
Green Medium
Blue Small
Blue Medium

From the following table - PRODUCT

ProductID  Name  ProductTypeID. 
1  Red  1
2  Green  1
3  Blue  1
4  Small  2
5  Medium  2

This is from the same table, I am having a complete brain fog moment. Any suggestions?

Thanks!

Upvotes: 0

Views: 22

Answers (1)

Bernd Buffen
Bernd Buffen

Reputation: 15057

try this:

SELECT CONCAT(p1.Name, ' ', p2.Name) as newName
FROM PRODUCT p1
CROSS JOIN PRODUCT p2
WHERE p1.ProductTypeID = 1 AND p2.ProductTypeID =2

Upvotes: 1

Related Questions