Hi,
You can do something like that :

mysql> select * from son;
+------+
| a    |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.02 sec)
mysql> select * from mother;
+------+------+
| a    | b    |
+------+------+
|    1 | a    |
|    1 | b    |
|    2 | a    |
|    2 | c    |
|    3 | a    |
|    3 | b    |
|    3 | c    |
|    3 | d    |
+------+------+
8 rows in set (0.00 sec)

mysql> select a,max(b) from mother 
    -> group by a;
+------+--------+
| a    | max(b) |
+------+--------+
|    1 | b      |
|    2 | c      |
|    3 | d      |
+------+--------+
3 rows in set (0.00 sec)

The max will be used with your datetime column. The "son" table can not
be used, or joined to the mother.


Best Regards
--------------------
Mathias FATENE
 
Hope that helps
*This not an official mysql support answer
 


-----Original Message-----
From: Jeff McKeon [mailto:[EMAIL PROTECTED] 
Sent: lundi 25 avril 2005 21:01
To: mysql@lists.mysql.com
Subject: Query question


I have a table that contains records that link back to a main talbe in a
many to one configuration linked by table1.id = table2.parentid

Table1 (one)
Table2 (many)

I want to pull the latest records from table2 for each record in table1
where certain criteria applie.

So, if record 100 in table1 links to 5 corresponding records in table2,
I want to pull the latest record from table2 where table2.parentid = 100
and table2.user not like 'john'

There is a datestamp field in table2.

I just can't figure out how to do this.

Thanks,

Jeff


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to