siva
01-15-2004, 05:22 PM
I have three tables:
generic_form
---------------
formid
firstname
lastname
address1
address2
borrower
form_user
---------------
form_userid
userid
formid
form_history
-----------------
form_historyid
form_userid
created (timestamp)
There's a one to many relationship from form_user to form_history (form_history has mutliple entries for each form_history.form_userid)
I want to join the two tables, but only select the oldest entry in the form_history table.
The way I'd write this with a sub-query would be:
select fu.formid, fh.created, f.borrower, f.address1, f.address2, fs.form_status
from form_user fu, generic_form f, form_status fs, form_history fh
where fh.form_userid = fu.form_userid and fu.formid = f.formid and fh.created IN (select min(created) from form_history)
Please suggest alternatives without using the sub-query, as the MYSQL version I'm working with is pre 4.1.
Thanks!!!
generic_form
---------------
formid
firstname
lastname
address1
address2
borrower
form_user
---------------
form_userid
userid
formid
form_history
-----------------
form_historyid
form_userid
created (timestamp)
There's a one to many relationship from form_user to form_history (form_history has mutliple entries for each form_history.form_userid)
I want to join the two tables, but only select the oldest entry in the form_history table.
The way I'd write this with a sub-query would be:
select fu.formid, fh.created, f.borrower, f.address1, f.address2, fs.form_status
from form_user fu, generic_form f, form_status fs, form_history fh
where fh.form_userid = fu.form_userid and fu.formid = f.formid and fh.created IN (select min(created) from form_history)
Please suggest alternatives without using the sub-query, as the MYSQL version I'm working with is pre 4.1.
Thanks!!!