我爱编程

003,数据库的增,删,改操作

2018-04-16  本文已影响36人  rain129

数据库的操作主要是【增,删,改,查】,但是今天先学习一下比较简单的【增,删,改】,后面再单独学习【查】;

增 - insert

insert into 表名(字段名1,字段名2) values(值1,值2);
insert into 表名(字段名1,字段名2) values(值1,值2),(值1,值2) //一次插入多条数据

删 - delete 【一定带上where条件】

delete from 表名 where 字段名=条件值;

改 - update 【一定要带上where条件】

update 表名 set 字段名1=‘新值’, 字段名2=‘新值’ where id=3;
示例:
update user set username="张三", password="123456" where id=3;

另外记录下where条件的几种写法

1. where id=2
2. where id>=3 and id<=5
3. where id between 3 and 54. where id in(6,8,9)5. where id=6 or id=8 or id=9`

上一篇 下一篇

猜你喜欢

热点阅读