主题说我有问题。
假设我有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
如何存档请指导我。
答案 0 :(得分:3)
从amount
total amount
SELECT *
FROM tableName
WHERE `total amount` - amount > 0
答案 1 :(得分:2)
"SELECT `materials`,(`total_amount` - `amount`) AS `newAmount` FROM `materials` WHERE (`total_amount` - `amount`) > 0;"