I have a simple query:
SELECT t1.tbl,
t1.slug
FROM t1
WHERE tags = '%".$tag."%'
However, I need to augment my results with the data from other tables (t2, t3, t4 and t5). For example, if t1.tbl = 't2' I need to add from:
SELECT t2.title
FROM t2
WHERE t2.county = '".$county."'
which I could join like this:
LEFT JOIN ON (t1.rid = t2.id)
In each of there tables I'll filter by $county even though the column is named differently.
I've tried something like this:
SELECT t1.tbl,
t1.slug
FROM t1 A
LEFT JOIN (
SELECT title
FROM t2 B
WHERE A.tbl = 't2'
) ON (A.rid = B.id)
WHERE A.tags = '%".$tag."%'
Is there a way to combine all there into a single query?