DELETE P
FROM Product P
LEFT JOIN OrderItem I ON P.Id = I.ProductId
WHERE I.Id IS NULL
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 = '')