1. mysql插入数据

    insert into tb_student(num,name,mobile) values(10,'李四','13100000000');
  2. mysql插入数据,如果主键存在则更新

    insert into tb_student(num,name,mobile) values(10,'李四','13100000000') 
    on duplicate key update name='李四',mobile='1310000000';
  3. mysql插入数据,如果主键/某数据存在则放弃修改

    insert ignore into user values(4, "aaa"), (5, "bbb"), (6, "ccc");
    INSERT INTO table(column1,column2,column3 ...columnN)
    SELECT value1,value2,value3 ...valueN
    FROM dual
    WHERE NOT EXISTS(
       SELECT *
       FROM table
       WHERE value = ?
    );

瑾明达
1 声望0 粉丝

« 上一篇
Oracle基础指令
下一篇 »
redis指令