If you need only the fields that are present in tables table1 and table2, you can do
SELECT field1, field2, field3 FROM table1 UNION SELECT field1, field2, field3 FROM table2
If the fields have different names, but the same type of content you can do
SELECT tab1_id AS primary_key, tab1_name AS name, tab1_amount AS amount FROM table1 UNION SELECT tab2_id AS primary_key, tab2_name AS name, tab2_amount AS amount FROM table2
This will give you the result with primary_key, name, amount columns (this is just a random example)
If two tables contain completely different content, you should really use two separate queries.
Tim Meyer Jul 14 '11 at 11:01 2011-07-14 11:01
source share