Reputation: 14834
Suppose I wanna do a join between table 1 and other tables...table 1 contains a column that specifies which table that row should be joined with
eg:
Table 1:
entry | tableName
333 | table3
4444 | table2
111 | table3
so 333 should be joined with table3, 4444 with table2, etc....
is there a way to specify mysql queries to use the column values like this as the name of the table to be joined with the entry?
Upvotes: 2
Views: 1316
Reputation: 1175
You will have to fetch the result set from this table where you have the entry, table details & build a dynamic query. You will not be able to do this in a single query.
Not sure why you have such requirement. It's always best to know what are the tables & relationships to get the best possible join.
Upvotes: 1