SELECT * FROM users
INNER JOIN predprijatie ON users.mesto_rab = predprijatie.pred_id
WHERE user_visible=1 AND parent_id=0
ORDER BY CASE WHEN users_id = '$curUserId' THEN 0 ELSE 1 END, mesto_rab , name
SELECT * FROM favoriteworker WHERE myid = '$curUserId';
array(16) {
["users_id"]=>
string(2) "34"
["name"]=>
string(50) "ФИО"
["doljnost"]=>
string(61) "должность"
["mesto_rab"]=>
string(2) "43"
["user_date"]=>
string(10) "1989-12-22"
["user_visible"]=>
string(1) "1"
["prinaly"]=>
string(10) "2017-11-22"
["invalid"]=>
string(1) "0"
["phone"]=>
string(10) "00000000"
["pred_id"]=>
string(2) "43"
["all_name"]=>
string(8) "офис"
["short_name"]=>
string(0) ""
["parent_id"]=>
string(1) "0"
["lvl"]=>
string(1) "0"
["visible"]=>
string(1) "1"
["exp_date"]=>
string(10) "3000-00-00"
}
array(16) {
[0]=>
array(3) {
["fav_id"]=>
string(2) "37"
["myid"]=>
string(2) "34"
["fav_user_id"]=>
string(2) "34"
}
[1]=>
array(3) {
["fav_id"]=>
string(2) "38"
["myid"]=>
string(2) "34"
["fav_user_id"]=>
string(2) "11"
}
[2]=>...