[nycphp-talk] OT - MySQL select question
Rob Marscher
rmarscher at beaffinitive.com
Thu Dec 7 11:26:45 EST 2006
If you're using a MySQL version earlier than 4.1, subqueries aren't
available. Maybe that's why you got an error with Andy's query.
That's interesting about the query not working in Oracle. I wonder if
it's because field_name isn't specifically listed in the SELECT - like
it doesn't like the "GROUP BY field_name" when * is used for the field
list? I've read that MySQL allows you to GROUP BY fields not listed in
the field list, but other DBs give errors.
-Rob
Aaron Fischer wrote:
> That did it, thanks Rob and Andy.
>
> Rob's query did the trick. I was getting a MySQL error with Andy's
> that I hadn't been able to figure out.
>
> Cheers,
>
> -Aaron
>
>
> Rob Marscher wrote:
>> I'm pretty sure the subquery is redundant... I think this will work...
>>
>> SELECT * FROM table_name GROUP BY field_name HAVING COUNT(*) > 1
>>
>>
>>
>> Andy Dirnberger wrote:
>>
>>> SELECT * FROM table_name WHERE field_name IN (SELECT field_name FROM
>>> table_name GROUP BY field_name HAVING COUNT(*) > 1)
>>>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
More information about the talk
mailing list