I've got two tables with identical fields, news and updates. I want to
return an ASP record set with all the data from both tables, and then I
want to order it by the date. Of course, there's a possibility of
duplicate dates. I would prefer the record from the news table when
there are duplicate dates.
Right now, I'm using:
"SELECT * FROM News, Updates"
as my SQL string. Currently, the last date is in the Updates table, so
moving to the last record in the record set produces the desired result.
However, if a story is added to the news table, I doubt it's going to be
the last record in the record set.
Is there any way to sort the record set on the date field after the two
tables are joined?
Carl Olsen, MCSE
Des Moines, IA
If I'm understanding you right, what you need to do is use an outer join
with an ORDER BY clause. It should look like...
"SELECT * FROM News UNION SELECT * FROM Updates ORDER BY [whatever your
date field is called]"
Hope that solves your problem.
Scott Murdock
Intranet Applications Manager
Omnicom Group