【发布时间】:2011-06-03 05:26:05
【问题描述】:
我创建了一个包含以下列的 mysql 表...
item_price, discount, delivery_charge, grand_total
item_price、discount 和 delivery_charge 的值都因所考虑的项目而异,这些值将手动填写到表格中。
我想让mysql根据item_price、discount和delivery_charge的值填充grand_total列中的值,使用下面的公式...
grand_total = item_price - discount + delivery_charge
我可以在mysql中创建表结构时以某种方式为该列指定一个公式吗?我知道这可以使用 php 完成,但如果可能的话,我更喜欢数据库自动为我执行此操作。
【问题讨论】:
标签: mysql formula calculated-field