- A+
所属分类:数据库
增
插入一条记录 mysql->insert into mytable values('summer','m','1983-08-24'); 插入多条记录 mysql->insert into mytable select * from yourtable;
根据条件插入 mysql->insert into mytable select * from yourtable where key
='value';
删
删除一条记录 mysql->delete from mytable where name='summer';
改
修改一条记录 mysql->update mytable set sex='vm' where name='summer';
查
1.简单查找
1 2 | a.用as关键字:select name as '姓名' from students order by age b.直接表示:select name '姓名' from students order by age |
2.精确查找
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | a. 用in限定范围:select * from students where native in ('湖南', '四川') b. between...and:select * from students where age between 20 and 30 c. 比较测试符:(包括=,<>,<,<=,>,>=)select * from students where name = '李山' d. like:select * from students where name like '李%' (注意查询条件中有“%”,则说明是部分匹配,而且还有先后信息在里面,即查找以“李”开头的匹配项。所以若查询有“李”的所有对象,应该命令:'% 李%';若是第二个字为李,则应为'_李%'或'_李'或'_李_'。) e. []匹配检查符:select * from courses where cno like '[AC]%' (表示或的关系,与"in(...)"类似,而且"[]"可以表示范围,如:select * from courses where cno like '[A-C]%')注:关于这个字符我在mysql里用的时候mysql把它当两个普通自符处理的。 [^]stockname like '[^F-M]%' --------- (^排除指定范围) f. count()求总数,如:select count(*) from students (求学生总人数) g. avg(列)求平均,如:select avg(mark) from grades where cno=’B2’ h. max(列)和min(列),求最大与最小 |
历史上的今天:

我的微信公众号
我的微信公众号扫一扫