whenever you use an aggregate function (like count()), you have to use the
GROUP BY clause. put the rest of your columns there. ie:
SELECT phID, phCOL, COUNT(phID) As coPHOTOS FROM photos
WHERE phGROUP='#grid#' AND phCOL IS NOT NULL
GROUP BY phID, phCOL
chris olive, cio
cresco technologies
[EMAIL PROTECTED]
http://www.crescotech.com
-----Original Message-----
From: Michael Lugassy [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 6:11 AM
To: CF-Talk
Subject: Simple SQL SELECT
I'm trying to simply select a few colums from a table (phID,phCOL)
+ the count of that certain select each time into a variable (coPHOTOS)
SELECT phID, phCOL, COUNT(phID) As coPHOTOS FROM photos
WHERE phGROUP='#grid#' AND phCOL IS NOT NULL
GROUP BY phCOL
I keep on getting an error: Column 'photos.phID' is invalid in the select
list because it is not contained in either an aggregate function or the
GROUP
BY clause.
What is wrong? Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists