Я хочу, чтобы в моем запросе отображалось полеандидат_идентификатора, но проблема в том, что кандидат_ид является избыточным. Пожалуйста, помогите мне выйти из этой проблемы. Thankyou!
//The result of $select1:
5
5
6
Note: the rows must be 3 rows that's why the $select2 is must be 3rows only and not a redundant
//The result of $select2:
190220015443
190220015600
190220015443
190220015600
190220072659
//Must be the output of $select2:
190220072659
190220015443
190220015600
<?php
$quarter = '1st';
$year = '2019';
$select1 = mysqli_query($db, "SELECT MAX(number_votes) FROM inter_department_votes WHERE quarter = '$quarter' AND year_date = '$year' AND number_votes != 0 AND status = '1' GROUP BY dept_id");
while ($row1 = mysqli_fetch_array($select1)) {
$number_votes1 = $row1['MAX(number_votes)'];
$select2 = mysqli_query($db, "SELECT candidate_id, dept_id FROM inter_department_votes WHERE number_votes = '$number_votes1'");
while ($row2 = mysqli_fetch_array($select2)) {
$candidate_id2 = $row2['candidate_id'];
echo $candidate_id2 . " " . "<br />";
}
}
?>
PS. Я пытаюсь сгруппировать по запросу, но результат тот же. Пожалуйста, помогите мне из этой проблемы: - ((((