I’m using an old php script and have an error with this query. Since I’m not experienced with mysql, I couldn’t fix it.
"SELECT COUNT(p.postid) AS pid, p.*, t.* FROM ".TABLE_PREFIX."post AS p
INNER JOIN ".TABLE_PREFIX."thread AS t ON (p.threadid = t.threadid) WHERE
p.username='".$uname."'"
the error is
Mixing of GROUP columns (MIN(),MAX(),COUNT(),…) with no GROUP columns is illegal if there is no GROUP BY clause
I hope someone can help me
Like the error says, you can’t SELECT an aggregate function, such as COUNT, without grouping rows either explicitly (using GROUP BY) or implicitly (by just selecting the aggregate). To put it in less technical terms – you’re telling the database, “Look up all posts by this username, and the threads they belong to, and the number of posts”, and the database is answering you, “the number of posts in what?”.
So you’ll need to be more specific. If what you actually want is:
p.*from the SELECT, and addGROUP BY t.threadidto the end of the query.postagain to get the total post count.