Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Join With Next date less than

0 views
Skip to first unread message

hurt

unread,
Nov 23, 2010, 10:02:01 AM11/23/10
to
Alright this is a little hard to explain, but I have two tables of very
different data. Both tables have a date timestamp. The timestamps are not
going to match, but I need to join table2 on to table1 via the next date
equal to or less than.

So..

Table1

|Date|id|
|2010/10/22 13:55:20|10
|2010/10/22 13:56:18|11


Table2
|Date2|id2|
|2010/10/22 13:55:19|A
|2010/10/22 13:57:30|B

I want to join table2 onto table1 where the date is equal to or less than
the date but limit it to one per row in table1.

In the above example I would end up with

|2010/10/22 13:55:20|10|2010/10/22 13:55:19|A
|2010/10/22 13:56:18|11|2010/10/22 13:55:19|A

It would ignore the 2nd row in table2.


I know how to do a join in MySQL but am having some issues with knowing
if I can have mysql do the logic of joining the row in table2 equal to or
less than the date in table1 limit to 1 date.

Hope I am explain this well enough..


Thank you.

0 new messages