This query seems to work perfectly on my older machine. However, on my new machine with MySQL 5.7.14 and PHP 5.6.25 it throws the error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'pixel_perfect.users.id'; this is incompatible with sql_mode=only_full_group_by' in C:\wamp64\www
Here is what my query looks like:
$sql="SELECT id, password, COUNT(id) AS count FROM users WHERE email = :email LIMIT 1";
$stmt=$db->prepare($sql);
$stmt->bindValue(':email', $email);
$stmt->execute();
Why am I getting this error now and what can I do to resolve it?
user
only has 1 id right so couldn't you justgroup by
theid
? – Amulet