OT : help needed with a mySQL request

John Craig john at splash21.com
Fri Nov 22 14:51:32 EST 2013


It's not a complete solution to jbv's problem - just one quick example 
that will hopefully help him to move forward.
The '>' can be changed to '!=' to avoid future years - jbv can tweak to 
fit his own needs - or choose another method!

:)


On 22/11/2013 19:21, Peter Haworth wrote:
> On Fri, Nov 22, 2013 at 9:40 AM, John Craig <john at splash21.com> wrote:
>
>> mysql> SELECT * FROM data HAVING (SELECT COUNT(id) FROM data AS data2
>> WHERE name = data.name AND year < 2013) = 0;
>> +----+--------+------+
>> | id | name   | year |
>> +----+--------+------+
>> |  8 | Katy   | 2013 |
>> |  9 | Tracey | 2013 |
>> +----+--------+------+
>>
> Hi John,
> Don't think that will work if there are rows with years greater than the
> one he's looking for, for example:
>
> Katy 2010
> Katy 2011
> Tracey 2010
> Tracey 2012
>
> You'd still get Tracy and Katy selected.
>
> I'm learning something about mySQL though.  In SQLite, HAVING is a
> subclause of GROUP but looks like it can stand on its own in mySQL.
>
> Pete
> lcSQL Software <http://www.lcsql.com>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>





More information about the use-livecode mailing list