$query="Select distinct * from voucher_payment LEFT Join vouchers ON voucher_payment.voucher_id = vouchers.voucher_id LEFT JOIN payment_details ON voucher_payment.payment_id= payment_details.payment_id where paid_amount > 0";
$result = pg_query($conn,$query);
<th>File Name</th>
<th>Date Recieved</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($result))
{
$servicedate=$row['service_dos'];
$code= $row['cpt_code'];
$servicedate= substr($row['service_dos'],0,4) . "-". substr($row['service_dos'],4,2). "-". substr($row['service_dos'],6) ;
$query2="Select * from charge LEFT Join payment ON charge.charge_id = payment.charge_id where charge.cpt_code NOT LIKE '" .$code . "' AND charge.charge_treatment_date != '" .$servicedate . "'";
$result2 = pg_query($conn2,$query2);
$row2= pg_fetch_array($result2);
?>
<tbody>
<tr>
<td><?php echo $row['file_name']; ?></td>
<td><?php echo $row['parsing_date']; ?></td>
结果是:
File name Date
--------- --------
2943875897 2016-07-08
2943875897 2016-07-08
2943875897 2016-07-08
2943875897 2016-07-08
依此类推,我把不同但仍然相同的结果只是不同的名字,谁能告诉我什么似乎是问题?我也希望GROUP BY认为它会有所帮助,但它没有。