SELECT count(users.id) AS cid FROM users as users LEFT JOIN favorites ON favorites.uid_a = users.id AND favorites.uid_v = 0 RIGHT JOIN (SELECT uid, count(pid) as cnt_pid FROM `positions` WHERE pid IN (,38) GROUP BY uid) AS tpos ON tpos.uid=users.id WHERE reg_type=0 AND moder_check = 1 AND flg_active=1 AND in_search=1 AND (wcountry=303 OR wcountry=0) AND (wtown = 30929 OR wtown=0)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '38) GROUP BY uid) AS tpos ON tpos.uid=users.id WHERE reg_type=0 AND moder_' at line 3