I am trying to query a post, its count(replies) and count(likes) with the following SQL query:
SELECT *,
(SELECT COUNT(*) FROM Post WHERE P.Id = ThreadId),
(SELECT COUNT(*) FROM Like WHERE P.Id = Id)
FROM Post AS P
WHERE ThreadId = 0;
Unfortunately, this syntax seems to be incorrect. Where is my error, I can't quite figure it out. This is the error text generated by MySQL:
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 'Like WHERE P.Id = Id) FROM Post AS P WHERE ThreadId = 0 ORDER' at line 1