On Thursday, February 28, 2013 9:44:01 AM UTC-5, Erland Sommarskog wrote:
> mcnewsxp (
mcou...@mindspring.com) writes:
>
> > I have a student table and need to filter it based on existing records
>
> > on two other one to many tables. the two other tables will contain a
>
> > student_id and a signdate. so I only need the most recent signdate so
>
> > that I only get one record.
>
> > actually I only need to know if a matching student_id exists in each of
>
> > these two tables.
>
> > I can't seem to work it out. I can get the syntax for one sub query but
>
> > not two.
>
>
>
> I showed you just the other day the technique to get the most recent row.
>
>
>
> If you only want to find students that exists on both tables:
>
>
>
> SELECT ...
>
> FROM students s
>
> WHERE (SELECT *
>
> FROM tbl1 t1
>
> WHERE t1.student_id = s.student_id)
>
> AND (SELECT *
>
> FROM tbl1 t2
>
> WHERE t2.student_id = s.student_id)
>
>
>
>
>