function foo(){
var a = 1;
b = 3;
}
foo();
console.log(a) - undefined
console.log(b) - 3
PDO::errorInfo
.SELECT t1.id, t1.parent_id,t1.title,case when t2.cnt is null then 0 else t2.cnt end cnt FROM table t1
LEFT JOIN (SELECT parent_id, COUNT(parent_id) cnt FROM table
GROUP BY parent_id) t2
ON t1.id = t2.parent_id
$('#id').on('change',function(){
//ajax-ом подгружай регион и страну;
});