I have a logs
table where I store all kinds of log information. This table contains foreign_table_name
and foreign_table_id
columns.
When pulling in the logs, to verify that the foreign records still exists, I want to run a "variable" join statement, e.g. like this:
SELECT *
FROM `logs`
INNER JOIN `[logs.foreign_table_name]` ON
`[logs.foreign_table_name].id` = `logs.foreign_table_id`
How can I dynamically "generate" these table names?