I have two tables
1st table :-
id name dept
1  John dept1
2  Mary dept2
3  Dave dept3
4  John dept4
5  John dept5
2nd table :-
id submitter dept
1  Rupert    dept3
2  Joe       dept1
3  Lisa      dept2
4  Louise    dept4
5  Tom       dept5
what i would like is a query to allow people in the name column in the first table to only show records based on their matching departments eg John in table one will return the 3 records in table 2 (id 2,4 and 5)
So far i have tried SELECT * FROM table1, table2 WHERE table1.dept = table2.dept AND table1.name='John'
 
     
    