user2_id where user1_id is 1 (the user for whom we are recommending pages).user1_id where user2_id is 1.UNION operator to get a complete list of friends without duplicates.page_id that user 1 already likes.page_id from the Likes table where the user_id is in the list of friends obtained from step 3 and the page_id is not in the list of pages user 1 already likes from step 4.page_id as recommended_page.erDiagram
Friendship {
int user1_id
int user2_id
}
Likes {
int user_id
int page_id
}
Friendship ||--o{ Likes : "has"