Попробуй так:
select count(*),
users.id,
...distance(my.lat, my.lon, users.lat, users.lon) as distance,
case when users.id in (
select favorites.prefId
from favorites
where favorites.userId = ?) then true else false end as favorite
from users,
(
select users.lat,
users.lon
from users
where users.id = ?
) as my
where...