// Invoice Detail
$sql= " (select webreg__tax_invoice_item.description
,webreg__tax_invoice_item.unit_amount,webreg__tax_invoice_item.amount
from webreg__pending_order,webreg__tax_invoice_item
where webreg__pending_order.invoice_item_id = webreg__tax_invoice_item.id
and webreg__pending_order.username='$bp' and webreg__pending_order.status='Approve'
and (date(webreg__pending_order.process_date) between '$date1' and '$date2')
order by webreg__pending_order.process_date )
UNION ALL
( select webreg__tax_invoice_item.description
,webreg__tax_invoice_item.unit_amount,webreg__tax_invoice_item.amount
from webreg__pending_renew,webreg__tax_invoice_item
where webreg__pending_renew.invoice_item_id = webreg__tax_invoice_item.id
and webreg__pending_renew.username='$bp' and webreg__pending_renew.status='Approve'
and (date(webreg__pending_renew.process_date) between '$date1' and '$date2')
order by webreg__pending_renew.process_date )
UNION ALL
( select webreg__tax_invoice_item.description,webreg__tax_invoice_item.unit_amount
,webreg__tax_invoice_item.amount
from webreg__pending_transfer_in,webreg__tax_invoice_item
where webreg__pending_transfer_in.invoice_item_id = webreg__tax_invoice_item.id
and webreg__pending_transfer_in.username='$bp' and webreg__pending_transfer_in.status='Approve'
and (date(webreg__pending_transfer_in.process_date) between '$date1' and '$date2')
order by webreg__pending_transfer_in.process_date)
LIMIT $Page_Start,$Per_Page";
while($rows=mysql_fetch_array($result))
{
echo"<tr><td>".$i."</td><td>".$rows['description']."</td><td>".$rows['unit_amount']."</td></tr>";
$i++;
INSERT INTO [Table-Name] (Column1,Column2,Column3,...) SELECT (Column1,Column2,Column3,...) WHERE ...
รุ้ว่าไช้อันนี้ แต่ประยุกต์ยังไงกับ
Code (PHP)
$sql= " (select webreg__tax_invoice_item.description
,webreg__tax_invoice_item.unit_amount,webreg__tax_invoice_item.amount
from webreg__pending_order,webreg__tax_invoice_item
where webreg__pending_order.invoice_item_id = webreg__tax_invoice_item.id
and webreg__pending_order.username='$bp' and webreg__pending_order.status='Approve'
and (date(webreg__pending_order.process_date) between '$date1' and '$date2')
order by webreg__pending_order.process_date )
UNION ALL
( select webreg__tax_invoice_item.description
,webreg__tax_invoice_item.unit_amount,webreg__tax_invoice_item.amount
from webreg__pending_renew,webreg__tax_invoice_item
where webreg__pending_renew.invoice_item_id = webreg__tax_invoice_item.id
and webreg__pending_renew.username='$bp' and webreg__pending_renew.status='Approve'
and (date(webreg__pending_renew.process_date) between '$date1' and '$date2')
order by webreg__pending_renew.process_date )
UNION ALL
( select webreg__tax_invoice_item.description,webreg__tax_invoice_item.unit_amount
,webreg__tax_invoice_item.amount
from webreg__pending_transfer_in,webreg__tax_invoice_item
where webreg__pending_transfer_in.invoice_item_id = webreg__tax_invoice_item.id
and webreg__pending_transfer_in.username='$bp' and webreg__pending_transfer_in.status='Approve'
and (date(webreg__pending_transfer_in.process_date) between '$date1' and '$date2')
order by webreg__pending_transfer_in.process_date)
LIMIT $Page_Start,$Per_Page";