I would like to write a sql statement that lists a series of products that all belong to sets to be ordered one per set, and list through all of the products.
My products are organized like this.
Set 01
Product 01
Product 02
Product 03
Set 02
Product 06
Product 07
Product 08
Product 09
Set 03
Product 11
Product 12
Product 13
Product 14
Product 15
I’d like to create a sql query that organizes them like this
Set 01 - Product 01
Set 02 - Product 06
Set 03 - Product 11
Set 01 - Product 02
Set 02 - Product 07
Set 03 - Product 12
Set 01 - Product 03
Set 02 - Product 08
Set 03 - Product 13
Set 02 - Product 09
Set 03 - Product 14
Set 03 - Product 15
I can get a query of products grouped by set, but am unable to get one per set.
select
`product_set`.`product_id`,
`product_set`.`set_id`,
`product_set`.`order`
from
`product_set`
inner join
`sets`
on
`product_set`.`set_id` = `sets`.`id`
where
`condition` = true