我有一个包含员工项目的数组。有些员工有多个记录,因此有多个阵列。 例。最多可能有5条记录。
[7] => Array
(
[emp_num] => 13
[emp_name] => SMITH, BILL
[appropriation1] => 51000550000
[hours1] => 80.00
[sal/rate1] => 500.00
[default_pay] => Y
[total_hours] => 82.00
[gross] => 537.50
)
[8] => Array
(
[emp_num] => 13
[emp_name] => SMITH, Bill
[appropriation1] => 51000550005
[hours1] => .00
[sal/rate1] => .00
[default_pay] =>
[total_hours] => 82.00
[gross] => 537.50
)
[appropriation1],[hours1],[sal / rate1]是唯一重复的东西。所以我想最终得到
[7] => Array
(
[emp_num] => 13
[emp_name] => SMITH, BILL
[appropriation1] => 51000550000
[appropriation2] => 51000550005
[appropriation3] => 51000550005
[appropriation4] => 51000550005
[appropriation5] => 51000550005
[hours1] => 80.00
[hours2] => .00
[hours3] => .00
[hours4] => .00
[hours5] => .00
[sal/rate1] => 500.00
[sal/rate2] => .00
[sal/rate3] => .00
[sal/rate4] => .00
[sal/rate5] => .00
[default_pay] => Y
[total_hours] => 82.00
[gross] => 537.50
)
在sql中这会更容易吗?我只知道基本的sql,但是如果我将表连接到自身,我是否能够创建列而不是尝试操作数组?甚至可以看一看?
继承人基本的sql
select employeenumber,EMPLOYEENAME, APPROPRIATION, TOTALHOURS as hours, PAYSALRATE, DEFAULTPAYCODE
from DET
where RECTYPEIND = 'D'