I have the following code, that does only half of what I want it to, but executes without error
Code:
SELECT
properties.productId
, properties.propertyName
, finishes.workflowCode
FROM
finishes
INNER JOIN
(
SELECT
product_properties.productId AS productId
, property_definitions.productPropertyName AS propertyName
, product_properties.productPropertyValue AS propertyValue
, property_definitions.productPropertyLokkupTableName AS tableName
FROM
product_properties
INNER JOIN
property_definitions
ON
product_properties.productPropertyId = property_definitions.productPropertyId
) AS properties
ON
finishes.productFinishId = properties.propertyValue
I want it to do something like this:
Code:
SELECT
properties.productId
, properties.propertyName
, finishes.workflowCode
FROM
CONCAT( properties.tableName )
INNER JOIN
(
SELECT
product_properties.productId AS productId
, property_definitions.productPropertyName AS propertyName
, product_properties.productPropertyValue AS propertyValue
, property_definitions.productPropertyLokkupTableName AS tableName
FROM
product_properties
INNER JOIN
property_definitions
ON
product_properties.productPropertyId = property_definitions.productPropertyId
) AS properties
ON
CONCAT( properties.tableName, properties.propertyName ) = properties.propertyValue
but of course the CONCAT() does not convert the result from the subquerry, which is executed first and should be available for the main querry, from a string into an expression for the FROM and ON clauses.
Any idea how to achieve this?
Thanks,
David