SELECT Horse.name, Mare.name
FROM VS LEFT OUTER JOIN HV Horse
ON VS.Idhorse = Horse.Id
LEFT OUTER JOIN HV Mare
ON VS.Idmare = Mare.Idmare
I think that should do it. There are a few things to check out here - look into left outer joins (which pull all the data from VS and only the matching records in HV), and aliasing - "Horse" and "Mare" are both aliases for the HV table.
how can we have a value in Idhorse or Idmare that isn't in HV?
only if we were sloppy twice -- by failing to declare proper foreign keys, and then by not checking ourselves (which is what the database does for us with FKs)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.