-1

我有产品_A

Product_ID Product_Name Price Quantity 
11         MilkA 36     56    3
21         MeatB 123    78    23 
31         SugarA 29    45    333 

产品展示_B

Product_ID Product_Name Price Quantity 
21         MilkB 63     65    33  
22         MeatB 321    87    4345 
23         SugarB 92    54    232 

我想要这样的选择查询

Product_ID Quantity Quantity*Price
11         36       
21         123
31         29
21         63
22         321
23         92

我试试

SELECT
  Products_A.Quantity,
  Products_B.Quantity,
  Products_A.Quantity * Products_A.Price,
  Products_B.Quantity*Products_B.Price
  FROM products_A,
  products_B;

但这看起来没有格式化。细节

4

1 回答 1

2

如果您想要两个表的结果,您可以使用 UNION ALL。

SELECT
  a.Product_Id as product_Id, 
  a.Quantity, 
  a.Quantity * a.Price as total
FROM Products_A a
UNION ALL
SELECT
  b.Product_Id as product_Id,
  b.Quantity,
  b.Quantity * b.Price as total
FROM Products_B b
于 2013-05-13T09:59:25.743 回答