I have these tables:
classified:
classified_id (PK)
price
headline
cat_id // THIS IS ANYTHING FROM 1 TO 30 DEPENDING ON CATEGORY. IT IS SO THAT I CAN LINK WHICH CATEGORY TO USE IN THE CATEGORY TABLE BELOW
text
etc...
category:
cat_id (PK)
cat_name
category_options:
option_id (PK)
cat_id (FK) // FOREIGN KEY FROM CATEGORY TABLE...
option_name
option_values:
value_id (PK)
option_id (FK)
classified_id (FK)
value
How should I use join here, could anybody give me a quick example?
Here is an example of my setup:
category
cat_id cat_name
1 cars
category_options
option_id cat_id option_name
1 1 color
2 1 gearbox
option_values
value_id option_id classified_id value
1 1 22 red
2 2 22 manual
classified
classified_id price headline cat_id
22 5000 'test' 1 //for cars
I want to be able to retrieve all options and their values from one category (in this ex cars) by only 'knowing' classified_id (which is 22 in this case).
Basically, I need help with the join statement...
and please don't use aliases in the code to simplify it for me :)
Thanks