开发者

Column's value as table name

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜