MySQL Forums
Forum List  »  Newbie

Re: How to recuperate data from other records in the same table
Posted by: Barry Galbraith
Date: February 28, 2016 04:23AM

Join the dogs table to itself twice, with alias for sire and alias for dam.

SELECT dog_id
dogs.dog_name
dogs.dob
sire.dog_name as sire
dam.dog_name as dam
FROM dogs
JOIN dogs as sire
ON dogs.sire_id = sire.dog_id
JOIN dogs as dam
ON dogs.dam_id = dam.dog_id;

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
Re: How to recuperate data from other records in the same table
February 28, 2016 04:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.