sql server中根据一条语句查询出来的结果,有结果执行一条sql语句,没结果执行另外一条sql语句,如何写?
我知道用casewhen,但写出来有语法错误casewhen(selectcount(*)fromGL_CashTablet2wheret2.i_id='65')!=nu...
我知道用case when,但写出来有语法错误
case when (select count(*) from GL_CashTable t2 where t2.i_id='65')!=null
then
select * from GL_accvouch t1,GL_CashTable t2 where t1.i_id='65' and t2.i_id='65'
else
select * from GL_accvouch t1 where t1.i_id='65'
end 展开
case when (select count(*) from GL_CashTable t2 where t2.i_id='65')!=null
then
select * from GL_accvouch t1,GL_CashTable t2 where t1.i_id='65' and t2.i_id='65'
else
select * from GL_accvouch t1 where t1.i_id='65'
end 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询