Hi, folks. Suppose I need to create invoices for a set of customers, each invoice consisting of a block of customer information followed by a variable number of detail lines. Standard stuff, but I'm used to reading records instead of executing queries, so I'm a little confused here.

Do I use one query to gather the desired set of customers, and then loop through the set of customers, issuing a query for each customer's detail lines? Or do I use one query that gathers the desired set of customers AND their detail lines all at once?

In the first case, I see that many more queries are involved, while in the second case, the customer information is needlessly repeated in each row. However, the amount of data involved is not large enough to make a performance difference either way, so I'm asking more if there's a standard way.