From: John List
Date: December 28 2009 1:25am
Subject: Re: Is there a better way than this?
List-Archive: http://lists.mysql.com/mysql/219938
Message-Id: <4B3808FF.60904@gulfbridge.net>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="------------060503080807020107030207"
--------------060503080807020107030207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
On 12/27/2009 06:04 PM, Tim Molter wrote:
> I'm new to MySQL and I'm looking for some guidance. I have a table A,
> with two columns X and Y with the following data:
>
> | X | Y |
> 1 24
> 1 25
> 2 25
> 2 26
> 3 27
>
> I want my SQL query to return "2" following this verbose logic: SELECT
> DISTINCT X FROM A WHERE Y equals 25 and Y also does NOT equal 24.
Since y=25 is associated with both x=1 and x=2, there's no way a simple
select can result in 2.
Perhaps your assignment calls for the count() of the results?
select count(*) from A where y = 25
Good luck,
John
--------------060503080807020107030207--