filmov
tv
Sql - Insert if not exists query

Показать описание
sql insert if not exists
In many cases we need to insert a row by checking whether it is already available or not. First we need to find a row is present or not. then if it is present, we skip the insert process. If the row is not present, then we insert the row. This query will help to insert rows only if not present. You can use this query directly in your application, where you need to check the presence before insert.
The syntax is :
merge into tblname i
using (select ‘val1' as a1,‘val2' as a2,‘Val3' as a3, …. , ‘valN' as an) d
The example is
merge into items i
using (select '7' as itemid,'puri' as itemname,'25' as itemcost) d
Like us on FB
Subscribe Our Channel
In many cases we need to insert a row by checking whether it is already available or not. First we need to find a row is present or not. then if it is present, we skip the insert process. If the row is not present, then we insert the row. This query will help to insert rows only if not present. You can use this query directly in your application, where you need to check the presence before insert.
The syntax is :
merge into tblname i
using (select ‘val1' as a1,‘val2' as a2,‘Val3' as a3, …. , ‘valN' as an) d
The example is
merge into items i
using (select '7' as itemid,'puri' as itemname,'25' as itemcost) d
Like us on FB
Subscribe Our Channel