New mysql query Vs working on existing results

Lets say I’ve obtained a set of over 100 items using a single mysql query and displayed them. Now, I need only the items with a certain id. Am I better off using a new mysql query or working on the existing results using PHP conditional statements?

Why not get the items with the matching ID initially via SQL?

Because I need to display all the items before displaying those with a certain id.

If you already know what ID you need when you get the original set of data, why not do both at once?

Nothing stops you from running the id check during the display loop, and storing the results or whatever you want to do for later use.

1 loop through data is better than 2 loops.

So you need to get all 100 of them anyway? Well in that case you just need to sort them out via PHP. No use making another mysql connection.