INNER JOIN上的MySQL语句语法错误

时间:2015-09-27 17:00:12

标签: php mysql

此查询有什么问题?执行时,它会显示以下消息:

  

您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以获得正确的语法,以便在'INNER JOIN类别ON附近使用product.CategoryID = category.CategoryI WHERE product.Pro'在第1行

$filter = "SELECT product.ProductID,
           product.ProductName,
           category.CategoryName,
           product.ProductPrice,
           product.QuantityAvailable, "
           . "product.AddedDate,product.Status"
           . "INNER JOIN category ON product.CategoryID = category.CategoryID "
           . "WHERE product.ProductName LIKE '%$productName%' 
          AND category.CategoryName = '$productCategory' 
          AND " . "product.ProductPrice BETWEEN $productPriceFrom AND       $productPriceTo 
          AND product.QuantityAvailable BETWEEN $productQuantityFrom AND $productQuantityTo 
          AND " . "product.AddedDate BETWEEN '$productCreatedFrom' AND '$productCreatedTo' 
          AND product.Status = '$productstatus'";

1 个答案:

答案 0 :(得分:1)

您错过了查询中的FROM子句。

"product.AddedDate,product.Status "替换为

"product.AddedDate,product.Status FROM product "