mysql - UNION 2 Tables, (combining them) -


i have products_a

product_id product_name price quantity  11         milka 36     56    3 21         meatb 123    78    23  31         sugara 29    45    333  

products_b

product_id product_name price quantity  21         milkb 63     65    33   22         meatb 321    87    4345  23         sugarb 92    54    232  

i want select query this

product_id quantity quantity*price 11         36        21         123 31         29 21         63 22         321 23         92 

i try

select   products_a.quantity,   products_b.quantity,   products_a.quantity * products_a.price,   products_b.quantity*products_b.price   products_a,   products_b; 

but looks unformatted. details

if want results both tables, can use union all.

select   a.product_id product_id,    a.quantity,    a.quantity * a.price total products_a union select   b.product_id product_id,   b.quantity,   b.quantity * b.price total products_b b 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -