Query a database for empty tables In my system there are two tables called ‘faculty’ and ‘faculty_assets’.

I need to delete faculty by faculty from the ‘faculty’ table. But system should allow deleting the faculty when only faculty_assets table empty. Otherwise It should not allows to delete the faculties from ‘faculty’ table. 

Can anyone modify below sql query?  (‘fac_id’ is the primary key of ‘faculty’ table ) 

function removeFaculty($fac_id){
    $conn=new connection();
    $sql="delete from faculty where fac_id='$fac_id'";
    $result=$conn-&gt;query($sql);
    return $result;


}
Assuming faculty_assets and faculty are joined by the fac_id field, you could use something like 

$sql="DELETE FROM faculty WHERE fac_id='" . (int)$fac_id . "' AND NOT EXISTS 
        (SELECT * FROM faculty_assets WHERE fac_id = '".(int)$fac_id . "')";