Subject | Re: How to insert only if a matching row does not exist? |
---|---|
Author | gastrocus |
Post date | 2011-10-20T23:26:31Z |
--- In firebird-support@yahoogroups.com, Paul Vinkenoog <paul@...> wrote:
Cheers.
Ed
>Nice trick! That seems to work.
> > So, when I tested it on a table which had 100 rows (non matching the 'ZZZZZ' test), it inserted 100 new rows, each with a 'ZZZZ' name.
>
> Yes, if you want to use this trick, the _source_ table should have 1 row.
>
> So this works:
>
> merge
> into emp
> using (select 'mango' fruits from rdb$database) src
> on emp.fruits = src.fruits
> when not matched then insert (fruits) values ('mango')
>
Cheers.
Ed