Thanks, guys...

I decided to try Leigh's suggestion first, and it worked.

Thanks for the suggestions, everyone!

Rick :o)



-----Original Message-----
From: Leigh [mailto:[email protected]] 
Sent: Friday, August 12, 2011 2:02 PM
To: cf-talk
Subject: Re: How to write this MySQL query...


> - find all propertyID's from a table that had duplicate
> photo200 field values

If you mean _different_ propertyID's sharing the same photo200 value, you
would need to count by the photo200 column instead. Then match it with the
propertyID. 

One option is using a join. Another would be a subquery using where exists
...

select r.propertyID, pc.photo200, pc.TimesUsed
from   rentalphotos r  inner join
           (
                select photo200, count(*) as TimesUsed
                from   rentalphotos 
                group by photo200
                having count(*) > 1
           ) 
           pc on pc.photo200 = r.photo200 






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346730
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to