我在 mysql 中有一个名为“tables”的表,该表包含所有表名称和表 ID 的名称。
我需要对这个表做一个 INNER JOIN 并替换值{table}和{column_id}
SELECT *
FROM attributes_categories AS ac
INNER JOIN attributes_codes AS aco ON aco.id_attribute_code =
ac.attributes_codes_id_attribute_code
INNER JOIN {$table} AS b
LEFT JOIN translations AS t ON t.id = b.{$column_id}
我正在尝试这样的事情,但是,我无法替换“INNER JOIN {$table}”,因为我无法插入结果来代替表名:
SELECT COLUMN_NAME
FROM attributes_categories AS ac
INNER JOIN attributes_codes AS aco ON aco.id_attribute_code =
ac.attributes_codes_id_attribute_code
INNER JOIN tables AS tab ON tab.id_table = ac.tables_id_table
INNER JOIN INFORMATION_SCHEMA.TABLES ON TABLE_NAME = tab.table
INNER JOIN tab.table AS b
LEFT JOIN translations AS t ON t.id = b.column_id
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA='knskjhpumw1'
结果是:
Mensagens do MySQL :
#1146 - Tabela 'tab.table' does not exist
谢谢!
