我试图使用PDO执行查询,但它会引发错误。
SQLSTATE [42000]:语法错误或访问冲突:1064您有 SQL语法错误;查看与您的手册相对应的手册 MariaDB服务器版本,用于在''附近使用正确的语法在第3行
$db = PrestaDB::getInstance($shop->getHost(), $shop->getLogin(), $shop->getPassword(), $shop->getDbName());
$statement = '
SELECT *
FROM ps_orders o
JOIN ps_customer c ON c.id_customer = o.id_customer
JOIN ps_carrier car ON car.id_carrier = o.id_carrier
JOIN ps_address a ON o.id_address_delivery = a.id_address
JOIN ps_address ai ON o.id_address_invoice = ai.id_address
LEFT OUTER JOIN ps_customer_thread ct ON ct.id_order = o.id_order
LEFT OUTER JOIN ps_customer_message cm ON cm.id_customer_thread = ct.id_customer_thread
ORDER BY o.date_add DESC
';
if ($result = $db->query($statement)) {
while ($row = $result->fetch(\PDO::FETCH_OBJ)) {
print_r($row);
}
}
当我删除
LEFT OUTER JOIN ps_customer_thread ct ON ct.id_order = o.id_order
LEFT OUTER JOIN ps_customer_message cm ON cm.id_customer_thread = ct.id_customer_thread
从查询它工作正常。该查询有什么问题?