语法
delete from 表名 where 条件
语句
delete from student where sno=1;
注意1: 删除语句必须有where条件 如果没有 那么就是删除全部数据(后果很严重)
注意2: 删除语句的执行机制是扫描每一条数据 如果符合where后面的条件,即删除,否则不删除
------- 需要zi料+ 绿色徽【vip1024b】
语法
update 表名 set 字段1=值1 , 字段2=值2,… …,字段n=值n where 条件
语句
update student set classname =‘PHP’ where sno=1;
update student set score2=0;
update student set classname=‘java’,score2=100 where sname=‘张三’;
如果没有where条件 那么就是修改全部数据
逐条扫描数据 如果数据符合where条件 那么就对数据进行修改 否则 不修改
查询专训1 字段处理
– 最简单的SQL语句
select * from dept;
select * from emp; – * 所有列
select empno,ename,sal,comm from emp – 指定列
– 使用算术表达式
select * from emp;
select empno,ename,sal,sal12,sal12+1000 from emp;
select empno,ename,sal,sal*1.8 from emp ;-- 不是修改,没有改变原有的值
select * from emp;
– 使用别名
select empno,ename,sal,sal12 as “年薪”,sal12+1000 as ‘年薪2’ from emp;-- ()要小心了
select empno,ename,sal,sal12 年薪,sal12+1000 年薪2 from emp; --as可以省略
select empno,ename,sal Salary ,sal12 年 薪,sal12+1000 年薪(含年终奖) from emp;
select empno,ename,sal “Salary” ,sal12 “年 薪”,sal12+1000 “年薪(含年终奖)” from emp;
– 别名中如果有特殊字符双引号,如果区分大小写,要使用引号
select empno,ename,sal ‘Salary’ ,sal12 ‘年 薪’,sal12+1000 ‘年薪(含年终奖)’ from emp;
– 去重distinct
select * from emp
select empno,ename,job,deptno from emp
select job from emp – 还是14条记录,没有去重
– 查询一共有几种岗位
select distinct job from emp – distinct 有区别的; 去除重复
select job,deptno from emp; – 14
– 两位字段的组合去重
– order by
select * from emp – 默认不是按照编号排序的,是按照rowid排序的
select * from emp order by empno asc – asc 升序 可以省略
select * from emp order by empno desc – desc 降序
select * from emp order by sal
– 如果薪水相同,按照入职时间
select * from emp order by sal desc ,hiredate desc
select * from emp order by hiredate desc –
查询专训2 条件处理
行级数据筛选器,where字句,在查询数据时,对数据进行逐行扫描,过滤出符合条件的数据作为结果
要点如下
1 等值筛选规则
2 不等值筛选规则
3 模糊筛选规则
– 1等值查询语句
– 根据员工编号查询员工信息
– 根据日期查询
– 部门为20 或者职务为clerk
– 2不等值查询语句
最后
手绘了下图所示的kafka知识大纲流程图(xmind文件不能上传,导出图片展现),但都可提供源文件给每位爱学习的朋友
部门为20 或者职务为clerk
– 2不等值查询语句
最后
手绘了下图所示的kafka知识大纲流程图(xmind文件不能上传,导出图片展现),但都可提供源文件给每位爱学习的朋友
[外链图片转存中…(img-HQu4W3MI-1710362749452)]