I have a Table pages
and two other ones called page_options
and page_option_values
which make optional options possible without modify the table layout.
The tables have the following structure (shortend):
pages:
* page_id
* name
page_options:
* page_option_id
* name
page_option_values:
* page_id
* page_option_id
* value
Can I get a result from MySQL which selects all columns from pages
and shows the name column from page_options as virtual column
with value from page_option_values
?
EDIT:
I have the following Query now - but don't now why it don't work?
SELECT
n.page_id,
n.page_name,
a.column_name,
v.value as a.column_name
FROM pages n
JOIN page_attribute_value v on v.page_id = n.page_id
JOIN page_attributes a on a.attribute_id = v.attribute_id