UNION is your only way to improve this
in order for this to work, you have to select the same number of columns from each table, and the columns have to be datatype compatible
Code:
select 'link:' as rowtype
, linkName as data1
, url as data2
from topics
left outer
join links
on topics.id = links.topicID
union all
select 'news:' as rowtype
, newHeading as data1
, left(newText,255) as data2
from topics
left outer
join news
on topics.id = news.topicID
union all
select 'people:' as rowtype
, name as data1
, email as data2
from topics
left outer
join people
on topics.id = people.topicID
...
basically you are squeezing all of your queries into the same template for the result set (note you have to flag rows from each table with some sort of marker to indicate which table they came from, so that you will format them correctly on output)
Bookmarks