Reputation: 73
SELECT DISTINCT `model` from `goods`
Shows me all unique values of model in a table
SELECT DISTINCT `submodel` from `goods`
Shows me all unique values of submodel in a table
How could I request all possible combinations of model-submodel which exist in this table?
Upvotes: 2
Views: 137
Reputation: 343
These two queries will give you two tables which each one has only a column. So you can just do something like this:
Select *
FROM (SELECT DISTINCT `model` from `goods`) as A,
(SELECT DISTINCT `submodel` from `goods`) as B
This will give you all possible combination of model-submodel in this table.
This type of join is also known as CARTESIAN JOIN
Upvotes: 3