NiallThistle;10988131 wrote:That does actually correlate. There were eight records in the table.
But it is only displaying four of the results, the four I actually want it to - but it's displaying them all eight times.
Right, that's exactly what I would expect based on that query. Your WHERE condition eliminates some of the rows from the val_valuations table, but the remaining (four, apparently) rows are then used in a Cartesian product with every row in val_contracts.
NiallThistle;10988131 wrote:Which part of my code is causing it to count the total records and display each record that many times?
It's not a part of your code, it's the SQL query itself:
FROM val_valuations V, val_contracts T
That tells MySQL this: "Take every row in V and join it with each row in T." In other words, you're doing a Cartesian product, and you'll have |V| * |T| rows in the result set (where |V| and |T| are the number of rows in each table; so if V has 4 rows and T has 8 rows, your result set will contain 32 rows).
EDIT: Replied before I saw your most recent post.
That new WHERE condition will indeed eliminate those superfluous rows generated from the Cartesian product with the T table. Hopefully the reason for the difference in result sets is apparent now.