Mysql 需要MS Access中两个不同表中两列“项目数不同”之间的差异

Mysql 需要MS Access中两个不同表中两列“项目数不同”之间的差异,mysql,ms-access,Mysql,Ms Access,我需要我买的东西和我卖的东西之间的差异,我在这张表中买的东西 ID |ItemName| PriceOfUnit | NumberOfItems I bought |DateIBought| 1 | tea | 3 | 6 |15/11/2015 | 2 | coffee | 5 | 4 |16/11/2015 | 3 |

我需要我买的东西和我卖的东西之间的差异,我在这张表中买的东西

  ID   |ItemName| PriceOfUnit  | NumberOfItems I bought |DateIBought| 
  1    |  tea   |       3      |            6           |15/11/2015 |
  2    | coffee |       5      |            4           |16/11/2015 |
  3    |  tea   |       4      |            10          |20/12/2015 |
  4    | juice  |       5      |            15          | 1/1/2016  |
  5    | coffee |       3      |            5           | 15/3/2016 |
  6    | water  |       5      |            2           | 16/4/2016 |
  ID   |ItemName| PriceOfUnit  | NumberOfItems I sold   |DateIBought| 
  1    | coffee |       5      |            6           |  1/1/2016 |
  2    |  tea   |       5      |            9           | 15/3/2016 |
  3    | coffee |       4      |            2           | 20/4/2016 |
  4    | juice  |       5      |            11          |  1/1/2016 |
我卖的东西在这张桌子上

  ID   |ItemName| PriceOfUnit  | NumberOfItems I bought |DateIBought| 
  1    |  tea   |       3      |            6           |15/11/2015 |
  2    | coffee |       5      |            4           |16/11/2015 |
  3    |  tea   |       4      |            10          |20/12/2015 |
  4    | juice  |       5      |            15          | 1/1/2016  |
  5    | coffee |       3      |            5           | 15/3/2016 |
  6    | water  |       5      |            2           | 16/4/2016 |
  ID   |ItemName| PriceOfUnit  | NumberOfItems I sold   |DateIBought| 
  1    | coffee |       5      |            6           |  1/1/2016 |
  2    |  tea   |       5      |            9           | 15/3/2016 |
  3    | coffee |       4      |            2           | 20/4/2016 |
  4    | juice  |       5      |            11          |  1/1/2016 |
我需要在MS Access中使用查询、SQL查询或联合查询来获得此结果

  ID   |ItemName| NumberOfItems I have   |
  1    | coffee |            1           |
  2    |  tea   |            7           |
  3    | juice  |            4           |
  4    |  water |            2           |
我怎样才能得到这个结果?
其中NumberOfItems I have=NumberOfItems I buy-NumberOfItems I salled

您没有提供属性名或表名,并且指定了两个RDBMS产品,因此这里是解决方案的p代码:

问题1: 按ItemName从TBound GROUP选择ItemName、SumBuild作为SumBuild

问题2: 按ItemName从tSold组中选择ItemName、Sumsaled作为Sumsaled

问题3:
选择q1.ItemName,SumBunded-SumSaled作为与q1上的q1内部连接q2的差异。ItemName=q2。ItemName

nicomp太好了,谢谢,如果没有售出的商品,我需要显示我从该商品购买的编号如果我没有售出商品,它不会显示为我的示例它不会显示水