select table1.name, table2.deptid
from table1, table2
where table2.deptid=10 and table2.deptid=20