I have a MySQL database with multiple tables and those tables contain multiple columns that are equal.
For example:
table1
contains productid
, price
, and a couple of columns specific for that table.
table2
contains productid
, price
, and a couple of different columns (not in table1
)
table3
also has productid
, price
and more unique columns, etc etc.
Is it possible to select productid
and price
from all three tables in one query and get the result in one output? One way would be to select into some temporary table, but is there an easier/better/nicer way?
using the union :
select productid,price from table1
union select productid,price from table2
union select productid,price from table3
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