NYCPHP Meetup

NYPHP.org

[nycphp-talk] OT - MySQL select question

Andy Dirnberger dirn at dirnonline.com
Thu Dec 7 11:33:37 EST 2006


That's exactly why it doesn't work in Oracle.  I'm working against 9i right
now.  Maybe they added that ability in 10g.

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Rob Marscher
Sent: Thursday, December 07, 2006 11:27 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] OT - MySQL select question

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
>
_______________________________________________
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