I have tw tables with rows user\_id and I want to select all the users which appears in these two tables. That is, I want to select distinct userid from both tables and then find the corresponding users. How can I achieve this?

User (id, email) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

table1(user\_id) {1, 1, 2, 2, 2, 1}

table2(user\_id) {1, 3, 4, 10, 10, 10, 10}

dsitinct from table1 {1, 2}

distinct from table2 {1, 3, 4, 10}

after the join with user {1, 2, 3, 4, 10} with the respective email too