PDO SQL Bug?错误1140:混合GROUP列而没有GROUP列

时间:2017-09-25 23:48:07

标签: php mysql pdo

我有以下查询:

select
    count(*) as aggregate
from
    `images`
where
    `images`.`imageable_id` = ?
    and `images`.`imageable_id` is not null
    and `images`.`imageable_type` = ?
    and `generated` = ?
order by
    `order` asc

当我在MySQL REPL中运行它时,它运行得很好。但是,当我使用PDO在PHP中运行它时,我收到以下错误:

SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

我正在运行PHP版7.0.23-1+ubuntu14.04.1+deb.sury.org+1

有没有人提示如何诊断和解决这个问题?

1 个答案:

答案 0 :(得分:1)

为了将来参考,当两个到同一服务器的连接表现不同时,check the mode

事实证明,PDO正在strict模式下运行而MySQL REPL却没有。

相关问题