MySQL Union : Get two separate results back from a single query.
It is usually more efficient to query as much information from MySQL is one go as possible. Make the database do the work. Here we use a Union to effectively do two queries, two counts, one to count all records and the other to count all records that have a flag (subscribed) set (subset).
I'd recommend that you take a note of this generic query for future use. SELECT SUM(a.TOTRECORDS) AS total_shop_leads, SUM(a.SUBRECORDS) AS subscribed_shop_leads FROM (SELECT COUNT(*) AS TOTRECORDS, 0 AS SUBRECORDS FROM TBL_SHOP_LEADS UNION ALL SELECT 0 AS TOTRECORDS, COUNT(*) AS SUBRECORDS FROM TBL_SHOP_LEADS WHERE SUBSCRIBED) a

