【发布时间】:2011-12-27 13:25:04
【问题描述】:
首先抱歉,如果我的问题标题听起来很愚蠢......我有以下表格。第一个表包含我的费用类型的名称,第二个表包含这些费用的金额和日期信息。如果您注意到下面的第二个表,则有一个名为“e_id”的字段,它是第一个表中我的费用的相应 id 值。
第一个表名:expense_type
id expense_name
1 Insurance
2 Interest Payment
3 Rent
4 Electricity
... and goes on like this (unlimited perhaps :))
第二个表名:expense_details
id e_id amount date
1 3 1000 2011-12-11
2 1 500 2011-12-19
3 4 10 2011-11-21
4 3 1000 2012-01-12
... and goes on like this )
现在我的计划是从这两个表中获取所有值并生成如下结果。但由于第一个表有未知数量的信息(对我来说)我不知道如何编写查询(php 和 mysql)来生成这样的结果。
请您帮助我了解如何实现这一目标?
在此先感谢 :)
P.S 仅供参考,我正在使用 Codeigniter。
**For the Month: January 2011**
Insurance : 1000
Rent : 3453
Electricity : 546
Interest Payment : 546
---------------------------------
**Total Expenses**: 938949 /// this value is just for an example
【问题讨论】:
标签: php mysql codeigniter codeigniter-2