--SQL_Server 适用方法
if not exists (select * from table1 where mid='aa')
INSERT INTO table1(mid,name,msg) VALUES('aa','bb','cc')
--*可以改成其中的某字段
--oracle,mysql 适用方法
MERGE INTO table1 t
USING (select 'aa' mid from dual ) t2
ON (t.mid = t2.mid)
WHEN NOT MATCHED THEN
INSERT (mid,name,msg) VALUES('aa','bb','cc');
insert when exists(select * from table1 where mid = 'aa' ) into table1(mid,name,msg) select 'aa','bb','cc' from dual;