Hi,
Why my answer doesn't answer his question. Did you heared about his
comment. Let him do it.
If you're confused, i can explain more one-to-many relashionships. 

If you think about joins and want absolutely add them, this is the error
generating performance problems asked along all RDMBS, especially with
mysql (DBMS till now).

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


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: lundi 25 avril 2005 21:44
To: mathias fatene
Cc: 'Jeff McKeon'; mysql@lists.mysql.com
Subject: RE: Query question


"mathias fatene" <[EMAIL PROTECTED]> wrote on 04/25/2005 03:19:33 PM:

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

I think I am decent at what I do and that confused even me. I am totally

baffled at what SQL concept you were trying to illustrate.

How did you _help_ the OP?  The question that started this thread is an 
example of a common class of SQL problems and several solutions exist. 
Your "solution" neither answered his query nor was it explained to the 
point that made it comprehendable. Please, please try to be less
confusing 
(especially when responding to newbies).

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


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

Reply via email to