Q:

Select the field that ever fulfil condition

Employee Table
 NameId  Name
 1       Andy
 2       Peter
 3       Jason
 4       Thomas
 5       Clark

Employee - Supervisor Relations
NameId  SupervisorId (Refer to employee Id)
1       4
1       2
2       3
5       4

How can i select query to return search with all name that supervisor 'once' to be Thomas. So the result i want is like this.
Name  Supervisor
Andy  Thomas       
Andy  Peter (Is valid because Andy supervisor contains 'Thomas')
Clark Thomas

A:

It looks the table relation doesn't need another optional table, so the query would be more simple:
select emp.name as Name, spv.name as Supervisor
from employee emp
inner join employee spv
   on emp.spv_id = spv.id
where spv.name like 'Thomas'
order by emp.name

