Hi
I'm trying to create a page for a stallion showing his offspring. I used the distinct query in the hope of showing each of his children only once, but I'm assuming that because the other data in the row differs (there is a unique reference number called runid) the foals are showing multiple times, as shown here: http://www.arabianraceform.co.uk/breeding/sires/00001.php
Below are PDF versions of the data in each table (just the data that applies to thus stallion):
Horse table: http://www.arabianraceform.co.uk/breeding/sires/2014-02-23_horses.pdf
Runners table: http://www.arabianraceform.co.uk/breeding/sires/2014-02-23_horses.pdf
I'm looking to produce a scenario where each foal is listed just once, preferably using their last run in the runners table as the record. Any advice on how I could adapt my current code (pasted below) to produce this result would be much appreciated.
<?php $result = mysqli_query($con, "SELECT DISTINCT horse.horse, horse.h_link, horse.h_ctry, horse.colour, horse.gender,
horse.dam, horse.s_link, horse.d_link, horse.d_ctry,
runners.raceid, runners.horse,
SUBSTRING(runners.raceid,1,4) AS raceyear
FROM horse
INNER JOIN runners
ON horse.horse = runners.horse
WHERE horse.s_link = '00002.php'
ORDER BY horse.horse");
include($_SERVER['DOCUMENT_ROOT'].'/inc/tables/breeding/sires.php');?>