that's the part that doesn't make sense
by the way, i'm looking only at the first SELECT in the UNION, the group stuff will have to come later
let's consider some sample data
let's say that $profileUserID equals curly
so the first part of the join (in the first SELECT), where you want user <> 'curly', that will retrieve
then for ~each~ of these, you are joining to the friends table, and the result of this join is
note that dick and larry were eliminated from the inner join, because each has no friends
did you follow that?