View Single Post

   
  #1 (permalink)  
Old 04-29-2008, 08:28 PM
md
 
Posts: n/a
Default conditional insert with values; insert into .. values(...) where notexist (....);

This is what I wish I could to do.

insert into table_x (a, b, c)
values(1, 2, 3)
where not exist (select * from table_x where a = 2);

Thank you.




additional info:
I've seen conditional inserts without values(....), as in

INSERT INTO clients
(client_id, client_name, client_type)
SELECT supplier_id, supplier_name, 'advertising'
FROM suppliers
WHERE NOT EXISTS (SELECT *
FROM clients
WHERE clients.client_id =
suppliers.supplier_id);

Reply With Quote