$sql = "SELECT sid, nombre, subnombre FROM empresas AS e LEFT JOIN subempresas AS s ON e.sid = s.sid WHERE s.sid = '$id'";