OT : help needed with a mySQL request

John Craig john at splash21.com
Fri Nov 22 11:44:54 EST 2013


If I understrand correctly, you have data similar to below;

mysql> select * from data;
+----+------+------+
| id | name | year |
+----+------+------+
|  1 | John | 1972 |
|  2 | John | 2006 |
|  3 | John | 2010 |
|  4 | John | 2013 |
|  5 | Kyle | 2006 |
|  6 | Kyle | 2010 |
|  7 | Kyle | 2013 |
|  8 | Katy | 2013 |
+----+------+------+

and you only want the 'Katy' record.  Here's one possible query;

mysql> SELECT *, (SELECT COUNT(id) FROM data AS data2 WHERE name = 
data.name AND year < 2013) AS yCount FROM data WHERE year = 2013 HAVING 
yCount = 0;
+----+------+------+--------+
| id | name | year | yCount |
+----+------+------+--------+
|  8 | Katy | 2013 |      0 |
+----+------+------+--------+


:D


On 22/11/2013 15:47, jbv at souslelogo.com wrote:
> Hi list,
>
> I have a table with a Date column (among others).
> Each entry has a date that ranges from 1930 to 2013.
> For several entries, the content of other columns can be similar,
> only the Date value changes. For instance I can have
>   aaa 2004
>   aaa 2013
> I need to find with 1 single request all entries with Date = 2013
> that don't exist in the table with other Date values.
> I tried SELECT * FROM myTable WHERE MIN(Date) = 2013
> but that returns an error #1111 - Invalid use of group function
>
> Any help would be much apreciated.
> Thanks in advance.
> jbv
>
>
> _______________________________________________
> 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