我正在尝试执行以下查询:
$query = "SELECT O. * AS NUM FROM (ab_order O)
LEFT JOIN ab_user U ON (O.id_user=U.id)
WHERE O.id IN ( SELECT OT.id_ab_order FROM ab_order_transaction OT
LEFT JOIN ab_transaction T ON (OT.id_ab_transaction = T.id)
LEFT JOIN ab_user U ON (T.id_user = U.id)
WHERE T.validated = 1 {$condTrans} ) {$condOrder}
ORDER BY {$orderCol} LIMIT $from, $numRecords ";
$queryDB = $DB->queryExec($query);
在实时服务器上:
但我需要使用localhost:
在localhost上它说:
MySQL error: 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS NUM
FROM (ab_order O)
LEFT JOIN ab_u' at line 1.
是否有更简单的方法升级实时服务器Mysql数据库?
答案 0 :(得分:2)
所有列的别名似乎都不正确:SELECT O. * AS NUM
。我不确定为什么它可以在以前的版本上运行,但应该删除as num
,或者每列应该明确别名。
答案 1 :(得分:1)
您可以在SELECT中为单个列定义别名。这是问题
SELECT O. * AS NUM
而不是使用
SELECT O. *