I have a query in MySQL using php. The query is below
$sql = "select m.id, s_1.username player_1, s_2.username player_2, current_step, won
from {$table_prefix} match m left join {$table_prefix}session s_1 on s_1.id = player_1
left join {$table_prefix}session s_2 on s_2.id = player_2
where current_step < 10";
The problem I’m having the query works great but when it needs to be executed quickly(back to back) I’m getting duplicated rows. How would I go about preventing duplicate rows.
Thank you.
You will need to use a DISTINCT to get only unique return rows.
http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html