Subject | [firebird-support] Re: How to insert only if a matching row does not exist? |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-10-21T06:44:43Z |
>Just realized you can make it even easier:An alternative (just an alternative available on all Firebird - and probably many InterBase - versions, the MERGE construct requires a not all-to-old Firebird version) would be:
>
> merge
> into emp
> using rdb$database
> on emp.fruits = 'mango'
> when not matched then insert (fruits) values ('mango')
INSERT INTO emp (fruits)
select 'mango' from rdb$database
where not exists (select *
from emp
where fruits = 'mango')
Set