select t1.uid from (select uid from table1) t1 inner join (select uid from table2) t2 where t1.uid=t2.uid