仔细说说你想做什么判断操作 select (case when aa = 'a' then 'A01' when 'b' then 'A02' else aa end) aa, (case when bb between 1 and 10 then 10*bb else bb end) bb, cc from tb
查询出来判断的话使用When case 就可以了
我想实现这样的功能Col1 col2 col3 AA BB CCIf (col1='?') and (col2 like '%??%') Begin ... End我不知道如何表达字段col1,col2等等
1、如果楼主只想更改列查询出的值,那么:select (case when col1 = 'a' and col2 like '%b%' then '正确' else '错误' end) col from tb2、如果楼主是想按查询出的列值来执行某些类似update、delete等SQL语句,那么:if exists (select 1 from tb where col1 = 'a' and col2 like '%b%') --SQL如果针对每一行都去判断执行某些SQL语句,游标吧!
select (case when aa = 'a' then 'A01' when 'b' then 'A02' else aa end) aa,
(case when bb between 1 and 10 then 10*bb else bb end) bb,
cc
from tb
AA BB CCIf (col1='?') and (col2 like '%??%')
Begin
...
End我不知道如何表达字段col1,col2等等
1、如果楼主只想更改列查询出的值,那么:select (case when col1 = 'a' and col2 like '%b%' then '正确' else '错误' end) col
from tb2、如果楼主是想按查询出的列值来执行某些类似update、delete等SQL语句,那么:if exists (select 1 from tb where col1 = 'a' and col2 like '%b%')
--SQL如果针对每一行都去判断执行某些SQL语句,游标吧!