ORCAL过滤筛选

select *from SC;
select sno,grade,cno from sc where cno=2;
--字符和日期日期需要单引号(要区分大小写)
select *from course;
select cname,cpno from course where cname = '数学';
--当查询像‘1994/6/7’如何查旬?(会面有更简便的方法)
--where hire_date = '7-6月-1994'
--where to_char(hire_date,'yyy-mm-dd') = '1994-06-07'
--比较符号<>不等于
--between and
select cno,cname from course where cno>2 and ccredit = 2;
select cno,cname from course where cno between 1 and 6; --包含边界
--in
select cno,cname from course where cno=1 or cno=2 or cno = 4;--也可以使用in
select cno,cname from course where cno in(1,2,4);
--模糊查询
--like
select cno,cname from course where cname like '数%';--首位含有'数'
--如何表示特定位?’_‘占一个字符
select cno,cname from course where cname like '_作%';--查询第二个值为‘作’
select cno,cname from course where cname like '__系%';--查询第三个值为‘作’
--如何查询有下划线的元素
select *from student;
update student  --更新数据
set sname = '李_勇'
where sname = '李勇'
select sno,sname,ssex from student where sname like '%\_%'escape '\' --用转义字符(字符可自定义)
--输出空值
select *from course
select cno,cname,cpno from course where cpno is null;
--输出非空
select cno,cname,cpno from course where cpno is not null;

--排序
select cno,cname from course where cpno>1  order by cpno desc;--从大到小
select cno,cname from course where cpno>1  order by cpno asc;--从小到大
select cno,cname from course where cpno>1  order by cpno-- 默认小到大
select cno,cname from course order by cpno; -- 没有过滤条件,直接小到大排序
--如何多重排序:如果第一次排序后,还是出现了重复的数据,如何(以另一种筛选标准)进行第二次排序
select cno,cname from course where cpno>1  order by cpno asc,cname;
--起别名,输出
select cno,cname,cno*10 hello from course order by hello desc; --以cno=hello进行排序

你可能感兴趣的:(ORCAL过滤筛选)