SQL学习2_上
插入一个姓名为'T_TM'的员工 insert into user_tab(name) values(T_TM);查询员工包含'_'员工,使用\转义符, 如(like '%\_%' escape '\')
select * from user_tab where name like '%$_%' escape '$';
插入一个'的员工
insert into user_tab(name) values('''');
两个为一个单引号
查询佣金为null的员工
null不能参与运算(无穷大)
null能参与number/date/varchar2类型的运算
select * from user_tab where column is null;
查询佣金为非null得员工而且工资大于1500
select * from user_tab where (column is null) and (sal>1500);
查询员工工资为1000或1500或5000成员
select * from user_tab where sal in (1000,1500,5000);
注意:
如果列为字符串类型in后面为字符串类型,否则无效类型
如果为number等类型,字符串可以转换成number
select * from user_tab where sal in (10,20,'30');
IN不对null进行处理
查询职位是"MANAGER" 或者职位不是"ANALYST"的员工(方式一,使用!= or )
select * from user_tab where (column='MANAGER') or (column!='ANALYST');
select * from user_tab where (column='MANAGER') or (not(column='ANALYS'));
页:
[1]