这是我的mysql_query
$rs = mysql_query("SELECT calendar.datefield AS dateRow, po.po_no,cus_name,net FROM payments
RIGHT JOIN po ON payments.po_id=po.po_id
RIGHT JOIN calendar ON (DATE(po.po_date) = calendar.datefield)
WHERE calendar.datefield BETWEEN '$sDateFrom' AND '$sDateTo'
") or die(mysql_error());// AND payments.pay_status='Paid'
?>
我想从另一个表中选择另一个实体
prod_desc FROM del_details
如何使用相同的格式查询?
常用键是po_id
答案 0 :(得分:0)
根据您的需要添加LEFT / RIGHT加入..
$rs = mysql_query("SELECT calendar.datefield AS dateRow, po.po_no,cus_name,net, del_details.prod_desc
FROM payments
RIGHT JOIN po ON payments.po_id=po.po_id
RIGHT JOIN calendar ON (DATE(po.po_date) = calendar.datefield)
JOIN del_details ON payments.po_id=po.po_id
WHERE calendar.datefield BETWEEN '$sDateFrom' AND '$sDateTo'
") or die(mysql_error());// AND payments.pay_status='Paid'