标签:name min HERE not admin user 记录 mysql sele
1.插入数据的同时判断某个字段是否有重复的值
1.1插入单条记录
"INSERT INTO table (username, password) SELECT ‘小明‘, ‘123456‘ FROM dual WHERE not exists (SELECT * WHERE table.username=‘小明‘)"
1.2插入多条记录
"INSERT INTO table1 (table1_id, table1_name, table1_type) SELECT table2_id, table2_name, ‘admin‘ FROM table2 WHERE not exists (SELECT * FROM table1 where table1.table1_id = table2.table2_id)"
标签:name min HERE not admin user 记录 mysql sele
原文地址:https://www.cnblogs.com/nb08611033/p/10011034.html