Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>you need to pre-query per family to get the age of the oldest child that has an image, then get parent's name / image information... something like...</p> <pre><code>select PreQuery.parentID, p.Name ParentsName, c.childID, c.age, cp.imgUrl from ( select c.parentID, max(c.age) OldestChildAgeWithPicture from Children c, childrenPictures cp where c.pictureID = cp.pictureID group by c.parentID ) PreQuery, Parent p, Children c, ChildrenPictures cp where PreQuery.parentID = p.parentID and PreQuery.parentID = c.parentID and PreQuery.OldestChildAgeWithPicture = c.age and c.pictureID = cp.pictureID </code></pre> <p>The inner query is prequalifying just by parent, childs highest age that an image exists... So, if you have a family with 3 children, oldest has no picture, 2nd oldes DOES, the the 2nd oldest is the one that will show in the above query. Additionally, what do you want to do if a family has twins, and BOTH have pictures on file. This query would show BOTH children if age is based on actual integer representation. However, if age is computed based on date arithmetic and would be more accurate... Ex: one child born Jan 1 of year X, and within the same year, another child born Dec 1.... As of December, they would be the same integer based age, but one obviously 11 months older than the other. </p> <p>Additionally, if you want the oldest REGARDLESS of having a picture, the above query would have to be changed only slightly... let me know if this is what you are looking for.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload