你能帮我解决一下我的疑问。我检查我之前的查询表是否有效,但这不起作用。
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']."");
答案 0 :(得分:1)
您尚未在var arr = [2017, 4, 30];
function dateAsArrayYYYYMMDD(array) {
return new Date(array.toString().replace(/(\d+)/g, "'$1'"))
.toJSON().slice(0, 10).split("-");
}
// get last date in April as array of string values
var date = dateAsArrayYYYYMMDD(arr);
console.log(date);
// set date reflecting last date in March,
// assign to `date` variable identifier
arr[1] -= 1;
arr[2] += 1;
date = dateAsArrayYYYYMMDD(arr);
console.log(date);
子句中定义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
s。混合左右连接只会令人困惑。