I have two tables representing two forms that are connected each other but a form number. The second form records a number and a timestamp. This form can record multiple entries with a timestamp for each entry. I need a SQL statement that will return the first entry on Form2 based on the timestamp field labeled ddate. Table structure goes as follows:

Form1: form_num, name
Form2: form_num, score, ddate

select a.form_num, a.name, b.score, b.ddate
from form1 a, form2 b
where a.from_num=b.form_num
order by b.ddate
limit 1;

or

select a.form_num, a.name, b.score, b.ddate
from form1 a, form2 b
where a.form_num=b.form_num
and b.ddate = (select min(ddate) from form2 where form_num=a.form_num) c;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.