[eluser]Hani A.[/eluser]
I need some help figuring out how to efficiently return a number of records from two joined tables.
I have two tables: Accounts and Purchases. Essentially, I'd like to know how many Accounts have NOT made any Purchases.
Here's where I start:
Code:
$this->db->join('Purchases', 'Purchases.accountID = Accounts.accountID', 'left');
$query = $this->db->get('individuals_purchased');
$result = $query->result_array();
echo ($result->num_rows()); // shows the number of purchases
What that returns is the number of collective purchases made. What I need is the number of accounts that have NO purchases. (Maybe the first question to ask is, how do I get the number of accounts that HAVE at least one purchase rather than the NUMBER of collective purchases across all accounts, such as in the example above.)
Thanks in advance for any guidance!