/* Countries that have states newer than 1 day */ SELECT countries.id, countries.name FROM countries INNER JOIN states ON countries.id = states.country_id AND states.created >= DATE_SUB(CURDATE(),INTERVAL 1 DAY) UNION /* Countries that have states that have counties newer than 1 day */ SELECT countries.id, countries.name FROM countries INNER JOIN states ON countries.id = states.country_id INNER JOIN counties ON states.id = counties.state_id AND counties.created >= DATE_SUB(CURDATE(),INTERVAL 1 DAY) UNION /* Countries that have states that have counties that have cities newer than 1 day */SELECT countries.id, countries.name FROM countries INNER JOIN states ON countries.id = states.country_id INNER JOIN counties ON states.id = counties.state_id INNER JOIN cities ON counties.id = cities.county_id AND cities.created >= DATE_SUB(CURDATE(),INTERVAL 1 DAY) ORDER BY id ASC;