運算子
| 符號 | 解釋 |
|---|---|
| + | 加法 |
| - | 減法 |
| * | 乘法 |
| / | 除法,結果是浮點數 |
| = | 等于 |
| > | 大于 |
| < | 小于 |
| <>或者!= | 不等于 |
| >= | 大于或者等于 |
| <= | 小于或者等于 |
| 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 '張_';
%:表示零個或者多個任意字符,_:表示一個任意字符,\:表示轉義字符,“%”在字串中表示字符“%”,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/11261.html
標籤:Oracle
