1

正如主题所说,我对此有疑问。可以说我有 3 列的表。

materials | total amount | amount
==================================
mouse     | 5            | 2
keyboard  | 10           | 5
phone     | 5            | 5 

我用这个代码显示这个表。

$result = mysqli_query($con,"SELECT * FROM materials");
while($row = mysqli_fetch_array($result))
  {
  echo  $row['materials'] 
  echo  $row['total_amount']
}

现在我想像这样展示这张桌子。

materials | total amount 
========================
mouse     | 3           
keyboard  | 5

如何存档,请指导我。

4

2 回答 2

3

减去amount_total amount

SELECT *
FROM tableName
WHERE `total amount` - amount > 0
于 2013-08-27T01:47:42.627 回答
2
"SELECT `materials`,(`total_amount` - `amount`) AS `newAmount` FROM `materials` WHERE (`total_amount` - `amount`) > 0;"
于 2013-08-27T01:52:22.427 回答