[Solved] How to properly optimise mysql select statement


Unless there’s more to the picture, why not just query everything, ordered by section, to have the A-Z:

SELECT * FROM Main_Section ORDER BY section

… and then process the results with one loop, which could look something like this:

$sections = $connect->query("SELECT * FROM Main_Section ORDER BY section"); 

while ($row = $sections->fetch_array())
{
    echo $row['section'] . ' ' . '<p>' . $row['id'] . '</p><h3>' . $row['firstname'] . ' ' . $row['lastname'] . '</h3>'; 
}

solved How to properly optimise mysql select statement