I have a query which works fine in MySQL, however when I try to recreate the same query in PostgreSQL (same DB structure) I just get a syntax error.
MySQL:
SELECT ticket.queue_id, queue.name, article.create_time,
COUNT(article.id)
FROM article
JOIN ticket
JOIN queue
ON article.ticket_id=ticket.id
and ticket.queue_id=queue.id
GROUP BY ticket.queue_id
Postgres:
SELECT ticket.queue_id, queue.name, article.create_time,
sum(article.id) FROM article
JOIN ticket
JOIN queue
ON article.ticket_id=ticket.id
AND ticket.queue_id=queue.id
GROUP BY ticket.queue_id;
The error:
ERROR: syntax error at or near "GROUP"
LINE 7: GROUP BY ticket.queue_id;
^
I'm quite at a loss here, as I can't really pinpoint my error.
The same error appears when I leave out the 'sum' statement in the query.
Any help much appreciated.
table1 JOIN table2 ON condition. TheON conditionis not optional for anINNER JOIN(whichJOINwithout qualifiers is).