I d开发者_Python百科on't have enough experience with mysql language. I need a query that include a subquery where I select something from another table with table name like a value from current table's column value. The query is something like this:
SELECT * FROM `action_{$id}` as `action` INNER JOIN `{$id}` as `table` ON
(
(
action.father_id='0' AND //some condition
)
OR
(
action.father_id<>'0' AND
table.type_id IN
(
SELECT type FROM **action_{$id}.father_id** WHERE type_id='{$id}'
)
)
)
In this example action_{$id}.father_id(or action.father_id) contains the name of another table from my database.
Please excuse my bad english. Thank you!
No, this is not possible and indicates a structural error in your table design.
action_{$id}.father_id** WHERE type_id='{$id}'
Maybe it's just me but isn't that rather redundant?
精彩评论