INSERT INTO tblemailtemplates (type, name, subject, custom, message)
SELECT * FROM (SELECT 'product', 'Service Usage Limits Notification', 'Service Usage Limits Notification' as subject, '1',
'Dear {$client_name},<br><br>

Please be informed that your service: {if $service_domain}{$service_domain}{else}#{$service_id}{/if} ({$service_product_name}) has just reached its limits.<br>
Detailed information on the service usage:<br><br>

{if $limit} Allowed {$kind} usage: {$limit} {$unit}<br>
{if $usage} Your current usage: {$usage} {$unit}{/if}{/if}<br><br>

It seems that {if $periodDays}within the last {$periodDays} days {/if}you have exceeded the allowed limit with {$differenceUsageAndLimit} {$unit}.<br><br>

{$signature}'
 ) AS tmp
WHERE NOT EXISTS (
    SELECT name FROM tblemailtemplates WHERE name = 'Service Usage Limits Notification'
) LIMIT 1;