I have two tables that have the same structure; one contains permanaent data, and one is cleared and reset on a regular basis.
I need to make the same select statement work on both as if they were just one table
This is what I tried:
SELECT * FROM a
,b
WHERE 1;
Where a
and b
have the same structure;
You may be looking at using a UNION in you query:
Select * from a
UNION
Select * from b
Note: It is better practice to qualify your column names instead of using the * reference. This would also make the query still useful if your two tables underwent schema changes but you still wanted to pull back all the data the two tables had in common.
So you want one set of results that contains the contents of both tables? If so then you'll need to do something like this:
select a.col1, a.col2 from a where...
UNION
select b.col1, b.col2 from b where...
mysql union syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With