Use subquery result multiple times.

I have a sql code like this

SELECT * 
FROM friend
WHERE 
	character_id_a IN (
		SELECT player_character_id 
		FROM player_character
		WHERE game_account_id IN ('1', '2')
	)
	AND
	character_id_b IN (
		SELECT player_character_id 
		FROM player_character
		WHERE game_account_id IN ('1', '2')
	)
;

Is there a way to avoid double execution of the subquery? Thank you in advance for any help.

Can you try this?

SELECT
f.*
FROM
friend f
INNER JOIN player_character c ON (f.character_id_a =c.player_character_id OR f.character_id_b =c.player_character_id )
WHERE
c.game_account_id in (1,2)