Hi all,
Hope all's well. I've been working with PHP and MySQL for a while now, but i just can't get my head around this. I'm writing a script that generates an xml file to be used in a google shopping feed. I have all my products in one table and product options are stored in another table.
Currently i just query the products table for the products for my feed and it works fine. Now i want to include variations. So i need a way to query the products table but for products that do have variations have a separate row returned in the results of the query for each variation. Some won't have any variations though.
So say in my products table i have socks, shirts and shoes and of these i have 2 types of shoe, 3 colours of shirt and just one set of socks it would return 6 rows
socks
brown shoes
black shoes
red shirt
green shirt
blue shirt
I have tried a few things like running separate queries on each table or loops inside loops but they don't seem to do the job properly. I'm sure there's a way i can achieve it in one query or a more effect use of 2 queries, i just need to see the light 🙂
If anyone could help or point me in the right direction it would be a great help.
Thanks in advance