一.增
#向表中插入1条数据
1.insert into 表名(字段1,字段2,...) values(值1,值2,...)
#向表中插入多条数据
2.insert into 表名(字段1,字段2,...) values(值1,值2,...), (值1,值2,...),......
#向表中插入来自其他表的数据
3.insert into 表名1(字段1,字段2,...) select (字段1, 字段2, ...) from 表名2
二.删
#删除表中所有数据,(表还在)
1.delete from 表名
#按条件删除表中的数据
2.delete from 表名 where name = 'lincoco' and age = '18'
三.改
update 表名 set name = 'zg' where age = '19'
四.查
4.1一般查找
1.select * from 表
2.select * from 表 where id > 1
3.select nid,name,age as a from 表 where id > 1
注意:查询时尽量不使用通配符*,而是将字段列出来,这样查询效率会提高。
4.2.按条件查找
and/or/in/not in/between
4.3.模糊查找
where name like 'lincoco%' #百分号匹配多个字符
where name like '%lincoco'
where name like