打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[学习笔记] Oracle运算符、连接符、结果去重、范围查询、模糊查询

运算符

符号 解释
+ 加法
- 减法
* 乘法
/ 除法,结果是浮点数
= 等于
> 大于
< 小于
<>或者!= 不等于
>= 大于或者等于
<= 小于或者等于
AND 逻辑与
OR 逻辑或
NOT 逻辑非

字符串连接符

select '姓名:' || c.stuname || ', 课程:' || b.coursename || ', 成绩:' || a.score || '分。' as sxcj
   from score a, course b, stuinfo c
   where a.courseid = b.courseid
   and a.stuid = c.stuid;

查询结果去重

SELECT DISTINCT 列1,列2,列3... from 表名;

select distinct b.coursename, t.score
   from score t, course b
   where t.courseid = b.courseid
   and t.courseid = 'R20180101';

DISTINCT后面只有一个列时,表示的是单个字段查询结果去重

DISTINCT后面有多个列时,表示的是多个字段组合的查询结果去重,即所有字段的值全部一样才去重。

IN操作符

select t.stuid,
       t.courseid,
       t.score,
       b.stuname,
       b.sex,
       b.age,
       b.classno,
       b.grade
  from score t, stuinfo b
 where t.stuid = b.stuid
   and t.courseid = 'R20180101'
   and t.score in ('85','89','79');

BETWEEN...AND

select t.stuid,
       t.courseid,
       t.score,
       b.stuname,
       b.sex,
       b.age,
       b.classno,
       b.grade
  from score t, stuinfo b
 where t.stuid = b.stuid
   and t.courseid = 'R20180101'
   and t.score between '70' and '95';

LIKE模糊查询

select * from STUINFO t where t.stuname like '张%';
select * from STUINFO t where t.stuname like '张_';
  • %:表示零个或者多个任意字符。
  • _:表示一个任意字符。
  • \:表示转义字符,“%”在字符串中表示字符“%”。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
SQL高级查询——50句查询(含答案)
Sql server 2005学习笔记之约束
JAVA操作数据库总结之组件篇-Hibernate
[学习笔记] Oracle基础增删改查用法
数据库(三)分组查询,having条件,语句执行顺序,内连接,外连接,子查询
excel运算符
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服