你能帮我查询一下吗?我检查了我以前的查询表,但是它不能工作。
SELECT cj.customer_jd,
customertable.name,
customertable.ordersize,
cj.job_no,
cj.id,
cj.ordered_quantity,
cj.ordered_quantity,st.id AS sandingID,
st.*
FROM sandingtable AS st
LEFT JOIN customer_job AS cj ON
customertable.id=cj.customer_jd
RIGHT JOIN st ON cj.id = st.`job_id`
WHERE st.date= '$date' AND st.shift = '$shift' AND
st.sandingno=".$row['sandingno']."");
最佳答案
您尚未在customer_table
子句中定义from
:
FROM sandingtable st LEFT JOIN
customer_job cj
ON customertable.id = cj.customer_jd RIGHT JOIN
st
ON cj.id = st.`job_id`
WHERE st.date = '$date' AND st.shift = '$shift' AND
st.sandingno = ".$row['sandingno']."");
我不确定该如何解决,但也许是这样的:
from st left join
customer_job cj
on cj.id = st.job_id left join
customertable
on customertable.id = cj.customer_jd
. . .
笔记:
我将为
ct
使用别名customertable
,但其余查询使用。您应该在查询中一致地使用
customertable
。混合左右联接只是令人困惑。