table names on the fly
Posted: Tue Jun 21, 2005 9:59 am
I have an interesting problem brought on by poor db design. (not my design!!)
I have one table that contains a bunch of records. Each one of those records has a table associated with it. If there was a record ID 10 in the first table, there would be a table called rec10, and so on for all the records in table one. What I need to do is pull a field from the rec* table. Is there a way to change which table is being joined on a line to line basis?
I feel like the solution to this is on the tip of my tongue. I think I might need some more coffee.
I have one table that contains a bunch of records. Each one of those records has a table associated with it. If there was a record ID 10 in the first table, there would be a table called rec10, and so on for all the records in table one. What I need to do is pull a field from the rec* table. Is there a way to change which table is being joined on a line to line basis?
I feel like the solution to this is on the tip of my tongue. I think I might need some more coffee.