This is a Postgres database. I am attempting to pull dog breed names (Cane Corso, Labrador, etc) from a breed table, to display based on the foreign keys located in an animal table. My issue is the animal table has two foreign keys to this single breed table, and I keep getting errors with my query. The first breed name will return based on a left join, but the second I cannot get the name to display as I already have a left join. Below is a simplified outline of what I am attempting to do:
breed table (ID, BreedName)
animal table (ID, breedID, breed2ID)
SELECT animal.ID, breed.BreedName
FROM animal
LEFT JOIN breed ON animal.breedID=breed.ID
WHERE animal.ID='7';
What I need to do is also get the BreedName to join for animal.breed2ID which I am failing miserably at. I could easily hardcode the breed names and have them displayed in the application, but this is not conducive to changes, additions, or deletions of breed names in the database.