You should do as much as possible in the Query or Stored Procedure. Going back and forth is plain stupid. Although this example seems simple, there are more complex examples on that theme. Sometimes, your Stored Procedure will be better off creating a temporary table, inserting data in it and returning it than going back and forth 10,000 times. You might have a slower query that saves time on a greater number of records or that saves bandwidth.
Customers can have many orders.
In that case, the join was not there at all or was not there on all keys. That would return so many records that your query might take hours. It s a common mistake for beginners. Depending on the DB you use, you will need to specify the Join type you want in different ways. Note that in SQL Server, Microsoft suggests you use the joins like in the Corrected 2 instead of the joins in the Where Clause because it will be more optimized.