Getting PDO exception 42000 on PDO SQL query

This has been bugging me for a fair amount of time now and I can’t seem to find were the issue lies. This is the query I’m stuck at:

$stmt2 = $conn->prepare('SELECT a.[zone], b.[source_external_subscriber_id], SUM(b.[source_customer_cost]) AS [total]
    FROM billing_zones a INNER JOIN cdr b 
    ON a.[id] = b.[source_customer_billing_zone_id] 
    WHERE destination_account_id = :destinationId 
    GROUP BY b.[source_external_subscriber_id], a.[zone]');
$stmt2->execute(array('destinationId' => $destinationId));

The message I get:

Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘[zone], b.[source_external_subscriber_id], SUM(b.[source_customer_cost] AS [tota’ at line 1 in /home/integracion.php:14

Leave a Reply

Your email address will not be published. Required fields are marked *