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.