mpdinosaur
Programmer
Folks;
I have what I think is an unusual problem with a one-to-many relationship query.
First some background. I have a table containing vending machine info. The other table contains one record for each product for sale in the machine. There may be one product, there may be 100 or any number in between.
My problem is this: I need to be able to extract the data so the machine data and up to five of the products are in a record. If there are more than five products, the next record should have the same machine data and products 6 thru 10 (the next five products, or less). etc.
It should look like this:
MachA Prod1 Prod2 Prod3 Prod4 Prod5
MachA Prod6 Prod7 Prod8
MachB Prod1 Prod2 Prod3 Prod4
MachC Prod1 Prod2 Prod3 Prod4 Prod5
MachC Prod6 Prod7 Prod8 Prod9 Prod10
MachC Prod11 Prod12
Does anyone have any ideas? I'm a 20-year vet, but new to SQL. Thanks in advance.![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
I have what I think is an unusual problem with a one-to-many relationship query.
First some background. I have a table containing vending machine info. The other table contains one record for each product for sale in the machine. There may be one product, there may be 100 or any number in between.
My problem is this: I need to be able to extract the data so the machine data and up to five of the products are in a record. If there are more than five products, the next record should have the same machine data and products 6 thru 10 (the next five products, or less). etc.
It should look like this:
MachA Prod1 Prod2 Prod3 Prod4 Prod5
MachA Prod6 Prod7 Prod8
MachB Prod1 Prod2 Prod3 Prod4
MachC Prod1 Prod2 Prod3 Prod4 Prod5
MachC Prod6 Prod7 Prod8 Prod9 Prod10
MachC Prod11 Prod12
Does anyone have any ideas? I'm a 20-year vet, but new to SQL. Thanks in advance.
![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)