I have following arrangement of tables (tableX and tableY) are in similar pattern. And when i mean {object.table} I would like to have the real table there instead of a string. What now I do is I execute the following SQL for each entry in Object table. But I would like to know is there any SQL solution where I can do this is a single query.
SELECT
persons.person_id AS "person_id",
{object.table}.avl AS "available",
"{object.variable_name}" AS "variable_name",
FROM
persons
INNER JOIN {object.table} ON {object.table}.person_id = persons.person_id
WHERE
{object.table}.{object.column} = {object.code};
Object
- table (tableX, tableY)
- column
- code
- variable_name
tableX
- person_id
- more_info
persons
- person_id
UNION, perhaps you want the MySQL variant ofEXECUTE IMMEDIATE: dev.mysql.com/doc/refman/5.1/en/…, but I really couldn't tell, since I don't understand at all what it is you're trying to do.