title: SQL - Get total certification count from people on a planet (3 separate tables)
body: <p>I honestly have no idea how to approach this problem. I've gotten up to <code>SELECT name</code> and then I'm lost (kind of embarrassing).</p>
  
  <p>The problem: Find the number of certifications held by people grouped by planet. This should have two columns the first, "name" will be the names of planets that have at least one certification. The second column should be "CertCount" and will be the number of certifications held by people from that planet for example if Lee is certified in "Viper" and "Mechanic" and Kara is certified in "Viper" and they are both from Caprica, then the "CertCount" for caprica should be 3:</p>
  
  <pre><code>CREATE TABLE `bsg_cert` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `title` varchar(255) NOT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB
  
  CREATE TABLE `bsg_cert_people` (
    `cid` int(11) NOT NULL DEFAULT '0',
    `pid` int(11) NOT NULL DEFAULT '0',
    PRIMARY KEY (`cid`,`pid`),
    KEY `pid` (`pid`),
    CONSTRAINT `bsg_cert_people_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `bsg_cert` (`id`),
    CONSTRAINT `bsg_cert_people_ibfk_2` FOREIGN KEY (`pid`) REFERENCES `bsg_people` (`id`)
  ) ENGINE=InnoDB
  
  CREATE TABLE `bsg_people` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `fname` varchar(255) NOT NULL,
    `lname` varchar(255) DEFAULT NULL,
    `homeworld` int(11) DEFAULT NULL,
    `age` int(11) DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `homeworld` (`homeworld`),
    CONSTRAINT `bsg_people_ibfk_1` FOREIGN KEY (`homeworld`) REFERENCES `bsg_planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
  ) ENGINE=InnoDB
  
  CREATE TABLE `bsg_planets` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(255) NOT NULL,
    `population` bigint(20) DEFAULT NULL,
    `language` varchar(255) DEFAULT NULL,
    `capital` varchar(255) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `name` (`name`)
  ) ENGINE=InnoDB
  </code></pre>