时间:2021-07-01 10:21:17 帮助过:2人阅读
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)"
Mysql 高级语句
标签:name min HERE not admin user 记录 mysql sele