练习:1、向biao2插入以下信息
插入:1、‘张三’,‘1997-2-3’,6000
2、‘李四’,‘男’,‘1998-3-5’,4000
3、‘王五’,‘女’,‘1998-4-6’,7000,”软件开发”
Insert into biao2 set name=’张三’,birthday=’1997-2-3’,salary=6000;
Insert into biao2 set name=’李四’,birthday=’1998-3-5’,salary=4000, genter=’1’;
Insert into biao2 set name=’王五’,birthday=’1998-4-6’,salary=7000,resume=’软件开发’,genter=’0’;
练习2
将所有员工的工资增加1000
Update biao2 set salary=salary+1000;
将李四的工资改为5000
update biao2 set salary=5000 where name=’张三’;
给张三增加100
Update biao2 set salary=salary+100 where name=’张三’;
练习3:删除所有男员工
Delete from biao2 where genter=’1’;
删除表中所有数据
Delete from biao2;
练习4:
查询年龄大于10岁的员工信息,用年“龄”当别名
Select * from biao2 where now()-birthday>10;
练习5:
create table student(
id int(10) not null auto_increment,
CHI int(10),
ENG int(10),
name varchar(10) not null,
primary key(id)
);
mysql> Insert into student values('',80,97,'zhjk');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> Insert into student values('',60,78,'zhjyk');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> Insert into student values('',78,67,'dkdhk');
Query OK, 1 row affected, 1 warning (0.00 sec)
查询英语分数在80-90之间的
Select * from student where ENG between 80 and 90;
查询语文味81,82,83,84的学生
Select * from student where CHI in(81,82,83,84);
查询姓张的学生信息
Select * from student where name like”z%”;
查询不姓张的学生的总成绩
select *,(CHI+ENG) from student where name not like"z%";