Nested select statements not working

You need to identify the tables for each of the columns that have the same name. You should also be using an IN statement and not = for the department.

I can’t test this since I don’t have your DB but you can try this:

$sql = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . 
"dir_personnel as personnel where lname like '$search%' or fname like '$search%' or 
extension like '$search%' or personnel.department IN (SELECT id FROM " . $wpdb->prefix . 
"dir_departments as departments where departments.department like '$search%') order by lname");