Click to See Complete Forum and Search --> : SQL Question


Dudsmack
04-25-2005, 12:28 PM
Let's say I have two SQL tables:

table1
t1_id, t1_title
table2
t2_id, t2_title

I would like to return the titles and indexes from both tables in a single query, having the results ordered alphabetically by the titles.

How can I accomplish this? I'm thinking with UNION but I can't quite get things to work.

CardboardHammer
04-25-2005, 12:31 PM
SELECT title, id FROM
(SELECT title = t1_title, id = t1_id FROM table1
UNION
SELECT title = t2_title, id = t2_id FROM table2) X
ORDER BY title

Dudsmack
04-25-2005, 12:33 PM
Thanks!

CardboardHammer
04-25-2005, 04:57 PM
You're welcome :cool: