Transwiki:SELECT:搜寻资料
- Select 语句 Select 栏位 From 资料表
- Select * From loan – 选择 loan 资料表内的所有栏位的内容– 在 Oracle 里开启资料表浏览,就相当于此行指令
- Select branch_name From loan – 从一个资料表选择单一个栏位来看
- Select branch_name, loan_number From loan – 选择多个栏位,栏位间用逗号分隔
- Select distinct branch_name From loan – branch_name 栏位内若有重复的资料,也只会列出 一次,上页第 2 语句会列出所有的资料
- Select loan_number, branch_name, amount*100 From loan – 选择出的栏位若为“数字”、“货币”型态,可做数 学运算后再列出– 选择出的栏位若为“字串”型态,可串接其他字串再 列出
- Where 子句句
Select 栏位 From 资料表 Where 判断式
- Select loan_number From loan Where branch_name=‘Perryridge’ – 列出分部(branch_name)为 Perryridge 的贷款代码(loan_number) – 判断式的关系运算符号可为 =, >, <, >=, <=, <>
- Select loan_number From loan Where branch_name=‘Perryridge’ And amount>1200 – Where 子句中有超过一个判断式,可使用 And, Or, 或 Not 做逻辑运算
- Select loan_number From loan Where amount Between 900 And
1000 – 可使用 Between .. And .. 的范围运算 – 相当于 amount>=900 And amount<=1000 – 也可使用 Not Between .. And .. 运算