Mysql add, delete, modify and check basic operations (2)

Mysql add, delete, modify and check basic operations (2)

Three. Modification operation (update)

  • Syntax : update table name set column = expr [, column = expr …];//Modify the table, change the value of column (an attribute) in the table to expr, of course you can modify multiple at the same time;
    //change the surname Liu Change age to 20
select * from student where name like '刘%';
update student set age = 20 where name like '刘%';
select * from student where name like '刘%';
  • //Sentence explanation: 1. Since you want to modify a thing, do you first need to check what its original data looks like; 2. Then modify it; 3. After the last modification, check if you are Successfully modified.
  • operation result
    Insert picture description here

Four. Delete (delete)

  • Syntax : delete from table name [WHERE …] [ORDER BY …] [LIMIT …]l;
    //Delete age equal to 18
  select * from student;
  delete from student where age =18;
  select * from student;
  • operation result
    Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45665172/article/details/109555402