I'm writing a custom blog script and I want to get the latest blog entry and post it on the front page.
I have two tables comments and entries
The structure is as follows:
entries: pid (post no), user, time, entrytitle, entry
comments: cid (comment no), pid (no of related post), user, time, comment
I want to retrieve the user,time,entrytitle,entry and the number of associated comments. I've never used JOIN before.
"SELECT user,time,entrytitle,entry,COUNT(comment) AS 'comtotal' FROM entries JOIN ON entries.pid = comments.pid ORDER BY time DESC LIMIT 1";
When I try to query the db I get:
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 'JOIN ON entries.pid = comments.pid ORDER BY time DESC LIMIT 1'
I've tried comtotal with and without quotes without luck. I can't think what else it could be.