在其他报告上它工作正常,但是当我以某种方式进行连接查询时,从迄今为止不起作用,它什么都没有显示。
$stmt1 = $conn->prepare("SELECT * FROM sales_detail LEFT JOIN product ON product.productid=sales_detail.productid LEFT JOIN sales ON sales.salesid=sales_detail.salesid LEFT JOIN customer ON sales.userid=customer.userid WHERE product.supplierid='".$_SESSION['id'] ."'BETWEEN '$from' AND '$to' ORDER BY sales.sales_date desc");
$stmt1->execute();
答案 0 :(得分:0)
我认为你在Where条件中缺少日期字段?
$stmt1 = $conn->prepare("select * from sales_detail left join product on product.productid=sales_detail.productid left join sales on sales.salesid=sales_detail.salesid left join customer on sales.userid=customer.userid where product.supplierid='".$_SESSION['id'] ."' AND TABLE.DATEFIELD BETWEEN '$from' AND '$to' order by sales.sales_date desc");
$stmt1->execute();
答案 1 :(得分:0)
您正在使用多个where子句,您需要and
或or
运算符。
顺便说一下,请仔细阅读SQL INJECTIONS
$stmt1 = $conn->prepare("select * from sales_detail left join product on product.productid=sales_detail.productid left join sales on sales.salesid=sales_detail.salesid left join customer on sales.userid=customer.userid where product.supplierid='".$_SESSION['id'] ."' AND BETWEEN YOURFIELD_HERE '$from' AND '$to' order by sales.sales_date desc");
$stmt1->execute();