I have created a query, which populates a table, but I would like to omit any records that are already in the table. For example dogs_bfa_no = 1234 is already in the table to be populated and therefore I would like to populate with the next one in line
Any ideas / pointers appreciated code below -
// Select the distinct TRN's from totya
$query2 = "SELECT DISTINCT TRN FROM totya";
$result2 = mysql_query($query2);
while ($row=mysql_fetch_array($result2)) {
// For each Team Get the Top 4 Dogs
$team1 = $row["TRN"];
$query3 = "INSERT INTO totyb (TRN, Dogs_BFA_No, SumPoints)
SELECT TRN, Dogs_BFA_No, Sum(FB_Points) AS SumPoints FROM totya
WHERE TRN = '$team1'
GROUP BY Dogs_BFA_No
ORDER BY SumPoints DESC
LIMIT 4";
$result3 = mysql_query($query3);
}
mysql_free_result($result2);
Any ideas / pointers appreciated code below -
// Select the distinct TRN's from totya
$query2 = "SELECT DISTINCT TRN FROM totya";
$result2 = mysql_query($query2);
while ($row=mysql_fetch_array($result2)) {
// For each Team Get the Top 4 Dogs
$team1 = $row["TRN"];
$query3 = "INSERT INTO totyb (TRN, Dogs_BFA_No, SumPoints)
SELECT TRN, Dogs_BFA_No, Sum(FB_Points) AS SumPoints FROM totya
WHERE TRN = '$team1'
GROUP BY Dogs_BFA_No
ORDER BY SumPoints DESC
LIMIT 4";
$result3 = mysql_query($query3);
}
mysql_free_result($result2);