hello i have 3 tables : parent, children, childrenPicture s
Table parent
parentId | name
Table children
childId | parentId | pictureId | age
Table childrenPicture s
pictureId | imgUrl
no i would like to return all parent names with their eldest son's picture (only return parents that have children, and only consider children that have pictures)
so i thought of something like :
I would like to join the subquery but don't know how to do that, anywaysI can't figure out how to solve this...
Well if anyone has a hint i'd appreciate very much
Thank you very much,
guillermobytes
Table parent
parentId | name
Table children
childId | parentId | pictureId | age
Table childrenPicture s
pictureId | imgUrl
no i would like to return all parent names with their eldest son's picture (only return parents that have children, and only consider children that have pictures)
so i thought of something like :
Code:
SELECT p.name AS parentName, cp.imgUrl AS imgUrl FROM parent AS p RIGHT JOIN children AS c ON (p.parentId = c.parentId) RIGHT JOIN childrenPictures AS cp ON (c.pictureId = cp.pictureId)) [B]WHERE c.age IN (SELECT c.age AS age FROM children AS c GROUP BY c.parentId ORDER BY c.age DEST LIMIT 0,1)[/B]
Well if anyone has a hint i'd appreciate very much
Thank you very much,
guillermobytes
Comment