MySQL命令使用MySQL从两个不同的表中减去两个值

时间:2015-02-22 17:30:48

标签: mysql

TABLE NAME::NEWSALES
--------------------------------------------                                                          
NID |BRAND  | QUANTITY |   PRICE  |  TOTAL |
---------------------------------------------
1  | D&G    |   50     |  2250.0  | 112500 |        
2  | GUCCI  |   40     |  2150.5  |  86020 |
---------------------------------------------

TABLE ::索多特

-----------------------------------------------------------------
SID |BRAND|   SOLD     |  PRICE |   TOTAL | REMAINING QUANTITY |
-----------------------------------------------------------------
10  | D&G   | 20     |   900  |   180000 |     ?               |
11  | GUCCI |  10    |   5375 |    53750 |     ?               |
 -----------------------------------------------------

//我需要减去QUANTITY-SOLD = REMAINING QUANTITY //示例::如果我们从NEWSALES表中将'quantity'视为50,并从SOLDOUT表中将'sold'视为20  然后它应该给'50 -20 = 30'(剩余数量)

0 个答案:

没有答案