mysql inner join if value = true ( share system )
While I don't think anybody is going to be confident they know what you're asking based on the first revision of your "question," I hope the following statement will give you at least some form of direction with how to achieve your... goal, I guess.  Here is an SQL Fiddle in case you would like to see the query in action.  I can only assume you'll also be interested in learning about COALESCE, as illustrated in this SQL Fiddle.

SELECT  *
FROM    `UserPost` up
LEFT JOIN `User` u
    ON  up.shared_id = u.id
    AND up.share_in = 1
LEFT JOIN `Group` g
    ON  up.shared_id = g.id
WHERE   up.user_id = 1;