DELETE P FROM target_profile_tbl P LEFT JOIN target_tbl I ON P.id = I.profile_id WHERE I.id = (SELECT profile_name FROM target_profile_tbl WHERE profile_name = '')