
SQL求助 我有2条记录,有一个字段的值不一样 我现在想查询的时候
展开全部
用case when 大致如下
select case when count(*)=0 then (select col from tab where colid=otherid) else col end col from tab where colid=paraid
只能取一列,取多列需要多个case when
paraid为你的参数,otherid为另一行的标识
其实这个用存储过程就简单了,if else 既可
select case when count(*)=0 then (select col from tab where colid=otherid) else col end col from tab where colid=paraid
只能取一列,取多列需要多个case when
paraid为你的参数,otherid为另一行的标识
其实这个用存储过程就简单了,if else 既可

2022-08-05 广告
苏州蓝晓生物科技有限公司。标准化核心产品:公司拥有完整的琼脂糖介质、葡聚糖介质、聚甲基丙烯酸酯介质生产线,年产分离介质50000L,产品质量稳定并达到国际领先水平。核心优势:公司核心技术人员拥有近二十年不同基质的基球开发和官能化的丰富技术经...
点击进入详情页
本回答由苏州蓝晓生物科技有限公司_提供
展开全部
这个判断用一个存储过程做比较方便;
定义一个变量,将传入的值代入查询的记录数插入这个变量中,如:
select count(1) into v_count from table where table.id = iv_inid;
if v_count = 0 then
select * from table where table.id <> iv_inid;
else
select * from table where table.id = iv_inid;
end if;
定义一个变量,将传入的值代入查询的记录数插入这个变量中,如:
select count(1) into v_count from table where table.id = iv_inid;
if v_count = 0 then
select * from table where table.id <> iv_inid;
else
select * from table where table.id = iv_inid;
end if;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select case when a=a then a
when a <> a then '' end from table
when a <> a then '' end from table
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询