Something like this should work in MySQL, assuming datefield doesn't duplicate within table2 for a given t1key.

select
        t1.a, t1.b, t1.c, t2.datefield
from
        table1 t1 left outer join  table2 t2 on t1.id = t2.t1key
where
((t2.datefield = (select max(t2a.datefield) from table2 t2a where t2a.t1key = t2.t1key)) or t2.datefield is null)

If you can assume the other fields (a, b, c) will be unique, you could do something like (which shouldn't require a unique datefield):

select
        a, b, c, max(datefield)
from
        table1 t1 left outer join table2 t2 on t1.id = t2.t1key
group by
        a, b,c

This is off the top of my head, so sorry if I'm missing something with this. Short of raw rows, though, this isn't a very WO solution.

John Baldwin



On Monday Feb 18, 2008 1:30 PM, at 1:30 PM, James Cicenia wrote:

OK -

I need to join on a table that has multiple records. However, I want only to join on the record with the latest date.

I need this to be an left outer join.

Thanks,
James Cicenia
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jgilmorebaldwin%40mac.com

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to