LEFT JOINでJOIN先がない行を抽出するSQL分を紹介します。
表の結合にて、LEFT JOINでJOIN先がない行を抽出するにはJOIN先の表のカラムがNULLであることを検出すればできます。
select * from m_entry left join m_template on m_entry.templateid = m_template.id
where m_template.id is NULL
同じ方法で削除もできます
delete m_entry from m_entry left join m_template on m_entry.templateid = m_template.id
where m_template.id is null