INSERT INTO admins_groups (admin_id,group_id)
values (11,22) WHERE NOT EXISTS (SELECT admin_id FROM admins_groups WHERE admin_id=1 and group_id=14);
该操作 是错误的
INSERT INTO groups (admin_id,out_id) select admin_id,group_id from admins_groups WHERE NOT EXISTS (SELECT admin_id FROM admins_groups WHERE admin_id=1 and group_id=222) LIMIT 1;
如果符合后面的条件 可以插入多条数据,但 LIMIT 1 把它限制为一条
该操作 是错误的
INSERT INTO groups (admin_id,out_id) select admin_id,group_id from admins_groups WHERE NOT EXISTS (SELECT admin_id FROM admins_groups WHERE admin_id=1 and group_id=222) LIMIT 1;
如果符合后面的条件 可以插入多条数据,但 LIMIT 1 把它限制为一条
INSERT INTO groups (admin_id,out_id) select 1,group_id from admins_groups WHERE NOT EXISTS (SELECT admin_id FROM admins_groups WHERE admin_id=1 and group_id=222) LIMIT 1;
如果符合后面的条件 插入一条 admin_id = 1 的 数据.