【发布时间】:2014-11-10 19:29:31
【问题描述】:
- 我在数据库中有 (2) 个表:Products、ProductSold
产品
--------------------
| id | name | cost |
--------------------
101 | Jeans| 32
102 | shoes| 53
产品销售
----------------------------
| strNum | amtSold | sales |
----------------------------
100 | 83 | NULL
100 | 105 | NULL
我需要将 (amountSold * cost) 列相乘。
我需要在 ProductSold 表中的“sales”列中输入结果。
*注意:我有一个连接到我的数据库的 php 脚本,获取其中的数据,并将其显示在一个 html 表中。
|产品编号 |产品描述 |商店 | QTR |售出金额 |成本 |销售 |
101 Jeans 100 1 83 32
102 Shoes 100 1 105 53
【问题讨论】:
-
你怎么知道牛仔裤的销量是83?
-
给了。唯一没有给出的数据是销售列。
-
我的意思是,没有连接产品和产品销售表的列,那么您如何获得该信息?
-
其实有---> $sql = "select p.productId, p.name, ps.storeNumber, ps.qtr, ps.amountSold, p.cost, ps.sales FROM Products p内部加入 ProductSold ps on ps.productId = p.productId where storeNumber = 100";