View Single Post

  #4 (permalink)  
Old 10-25-2007
Captain Paralytic
 
Posts: n/a
Default Re: query with COUNT (what am I doing wrong?)

On 25 Oct, 12:27, panchettone <pan_che_ttone@non_morde.bau> wrote:
> > SELECT COUNT(v.id) cnt, v.title, v.desc, v.cat, u.username,
> > t.team_name
> > FROM videos AS v
> > INNER JOIN users AS u ON v.user_id = u.user_id
> > INNER JOIN team_members tm ON tm.user_id = u.user_id
> > INNER JOIN teams AS t ON tm.team_id = t.team_id

>
> a new error:
> [
> #1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP
> columns is illegal if there is no GROUP BY clause
> ]


Well that's basic GROUP BY syntax!

SELECT COUNT(v.id) cnt, v.title, v.desc, v.cat, u.username,
t.team_name
FROM videos AS v
INNER JOIN users AS u ON v.user_id = u.user_id
INNER JOIN team_members tm ON tm.user_id = u.user_id
INNER JOIN teams AS t ON tm.team_id = t.team_id
GROUP BY v.title, v.desc, v.cat, u.username, t.team_name

Reply With Quote