I acquired a 2 database tables, you have 165 records. For every of individuals, I acquired to see the 1-million-entry table and find out the number of occasions is all of individuals 165 records pointed out.

"odds_provider" has 165 records, "bettingoffer" includes a million records.

    $SQL = "SELECT
    odds_provider.id AS id,
    odds_provider.name AS name,
    COUNT(bettingoffer.odds_providerFK) AS betcount
    FROM odds_provider
    INNER JOIN
    bettingoffer
    ON bettingoffer.odds_providerFK = odds_provider.id
    WHERE 
    odds_provider.active = 'yes'
    GROUP BY
    odds_provider.id,
    odds_provider.name
    ORDER BY betcount DESC";

    $result = mysql_query($SQL);
    while ($db_field = mysql_fetch_assoc($result)) {
echo $db_field['id'] , " " , $db_field['name'] , " " , $db_field['betcount'] , "</BR>";
    }           

It will what's intended however it takes forever. It is possible to faster way?

You need to have the ability to join the 2 tables using SQL. It might be better to not perform a COUNT(*) though. You will get better performance by indicating the particular column you would like to count.

SELECT
  op.id,
  op.name,
  COUNT(bo.odds_providerFK) AS bet_offering_count
FROM
 odds_provider op
 INNER JOIN
 bettingoffer bo
  ON bo.odds_providerFK = op.id
 WHERE 
  op.active = 'yes'
GROUP BY
  op.id,
  op.name

That one ought to be faster, particularly if there very few inactive ids.

SELECT id, name, betcount
FROM (
  SELECT
    odds_providerFK as id,
    COUNT(*) as betcount
  FROM bettingoffer
  WHERE active = 'yes'
  GROUP BY odds_providerFK
  ORDER BY betcount DESC) as counts
USING (id);

It can be done in far better way using SQL Join queries. you do not have to look the second table for everybody record in first table. you are able to begin a JOIN relationship between your table.

it might be more useful should you have copied and pasted the schema meaning of each of your tables, however in general this is the way JOIN queris works.

kindly refer these tutorials about how exactly JOIN queries work.