I guess this should help

Select a.deptid, b.deptid, b.name from table1 a, table2 b
where a.deptid = b.deptid
and b.deptid = 20 or b.deptid = 10