I would say multiple queries would be the way to go.
My over the top unoptimized style would say
query1 = data sire1 dam1
query2 = SELECT * FROM horses WHERE name='$sire1'"
Something to that effect. That is if Sire and Dam are actually text fields and not numbers. If it is a number change name to id or what ever the number represents. I am sure if you give it a little bit someone may have a more optimized way to do this.