MySQL is a very powerful language that lets you run sub queries.  Sometimes this can prevent you from having to do two queries.  This would bring up a list of all of the users in your database and a total number of invoices they've had. {codecitation class="brush:sql"}SELECT name,(SELECT count(*) FROM invoices WHERE FROM users{/codecitation}