[ 笔记列表 ]
所属分类:MySQL
浏览:126
内容:
语句1、 insert into test_table (f1, f2, f3, f4, f5) select 'd1', 'd2', 'd3', 'd4', 'd5' where not exists(select id from test_table where f1='d1' and f2 = 'd2') ; 语句2、 insert into test_table (f1, f2, f3, f4, f5) select 'd1', 'd2', 'd3', 'd4', 'd5' from test_table where not exists(select id from test_table where f1='d1' and f2 = 'd2') limit 1; 建议使用语句1,语句2会查询test_table表,效率低。
链接:
|