这个语法用oracle怎么写
时间:2011-09-08
来源:互联网
begin
print 'a'
end
else
begin
print 'b'
end
这是一段msSQL的代码,oracle怎么写? 主要是判断一个变量中是否有特定值(这个是重点,如果要用到函数,帮忙把函数写一下,写具体点,因为查了很多资料都没有解决)
如果有执行有条件查询,没有 执行有条件查询(这个不是重点)
作者: a496393868 发布时间: 2011-09-08
select case when 'wang' like '%赵栋%' then 'a' else 'b' end from dual;
作者: dawugui 发布时间: 2011-09-08
作者: langxingcs 发布时间: 2011-09-08
case when 即可.
select case when 'wang' like '%赵栋%' then 'a' else 'b' end from dual;
作者: a496393868 发布时间: 2011-09-08
if (instr('wang', '赵栋') > 0) then dbms_output.put_line('a'); else dbms_output.put_line('b'); end if;
作者: opps_zhou 发布时间: 2011-09-08
SQL code
if (instr('wang', '赵栋') > 0) then
dbms_output.put_line('a');
else
dbms_output.put_line('b');
end if;
作者: a496393868 发布时间: 2011-09-08
这个在SQL WINDOW执行不了?
作者: lnuwhy 发布时间: 2011-09-08
SQL> with TAB as( 2 select '赵栋' WANG from dual 3 union all 4 select '张三' WANG from dual 5 union all 6 select '李四' WANG from dual 7 union all 8 select '赵栋' WANG from dual) 9 select case when WANG = '赵栋' then 'A' else 'B' end from TAB; CASEWHENWANG='赵栋'THEN'A'ELSE ------------------------------ A B B A SQL>
作者: xl_smlie 发布时间: 2011-09-08
case when 即可.
select case when 'wang' like '%赵栋%' then 'a' else 'b' end from dual;
这个在SQL WINDOW中测试通过,没有问题,楼主再试试
作者: rihyou 发布时间: 2011-09-08
select case when 'wang' like '%赵栋%' then 'a' else 'b' end from dual;
这个在SQL WINDOW执行不了?
作者: xl_smlie 发布时间: 2011-09-08
SQL> with TAB as( 2 select '赵栋' WANG from dual 3 union all 4 select '张三' WANG from dual 5 union all 6 select '李四' WANG from dual 7 union all 8 select '赵栋' WANG from dual) 9 select case when WANG like '%赵栋%' then 'A' else 'B' end from TAB; CASEWHENWANGLIKE'%赵栋%'THEN'A ------------------------------ A B B A SQL> --------WANG 加引号'WANG' SQL> with TAB as( 2 select '赵栋' WANG from dual 3 union all 4 select '张三' WANG from dual 5 union all 6 select '李四' WANG from dual 7 union all 8 select '赵栋' WANG from dual) 9 select case when 'WANG' like '%赵栋%' then 'A' else 'B' end from TAB; CASEWHEN'WANG'LIKE'%赵栋%'THEN ------------------------------ B B B B SQL>
作者: xl_smlie 发布时间: 2011-09-08
SQL> with TAB as( 2 select '赵栋' WANG from dual 3 union all 4 select '张三' WANG from dual 5 union all 6 select '李四' WANG from dual 7 union all 8 select '赵栋' WANG from dual) 9 select case when WANG like '%赵栋%' then 'A' else 'B' end from TAB; CASEWHENWANGLIKE'%赵栋%'THEN'A ------------------------------ A B B A SQL> --WANG 加引号'WANG' SQL> with TAB as( 2 select '赵栋' WANG from dual 3 union all 4 select '张三' WANG from dual 5 union all 6 select '李四' WANG from dual 7 union all 8 select '赵栋' WANG from dual) 9 select case when 'WANG' like '%赵栋%' then 'A' else 'B' end from TAB; CASEWHEN'WANG'LIKE'%赵栋%'THEN ------------------------------ B B B B SQL>
作者: xl_smlie 发布时间: 2011-09-08
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28