Reputation:
Is there any way to let two tables act as one? I have two identical tables, the only difference is that one contains recent data and the other one older data. Is there any way to do something like this?
select *
from customers a,
(rentals union archrentals) r
where a.serno = r.custserno
and r.rentaldate > YYYYMMDD;
Upvotes: 0
Views: 116
Reputation: 21
Use a temporary table
select *
INTO #allcustomers
from customers a,
(rentals union archrentals) r
where a.serno = r.custserno
and r.rentaldate > YYYYMMDD;
then you can use the temptable to query the results.
Upvotes: 0
Reputation: 7137
Why don't you create a view like this?
CREATE VIEW v_allRentals
AS
SELECT * form rentals
UNION ALL
SELECT * FROM archrentals
In this way you can use v_allRentals without worrying every time you create a query that you are forgetting the old ones.
Thanks, Mucio
Upvotes: 1