$sql1 = "select CODE,max(YR_SC),SUM_N,SUM_U from bse_prc_p where CDE_L='".substr($code,0,11)."' and SC_L='YN' and SUM_N is not null and SUM_U is not null "; 我想做个查询,比如 当CODE=‘%TW%’时,执行 SC_L=‘YW’,这个条件查询
当CODE=‘%HK%’时,执行 SC_L=‘YN’,这个条件查询
当CODE=‘其他’时,执行 SC_L=‘CN’or 'BH',这个条件查询这个怎么做?
当CODE=‘%HK%’时,执行 SC_L=‘YN’,这个条件查询
当CODE=‘其他’时,执行 SC_L=‘CN’or 'BH',这个条件查询这个怎么做?
case
when CODE like '%TW%' then 'YW'
when CODE like '%HK%' then 'YN'
else 'CN' or 'BH'
end
)
and SUM_N is not null and SUM_U is not null ";
这样写可以吗?
好像最后一个条件没有执行
怎么做啊?
$sql1 = "select max(YR_SC),SUM_N,SUM_U from bse_prc_p where CDE_L='".substr($code,0,11)."' and (select SC_L=
case
when CODE like '%TW%' then 'YW'
when CODE like '%HK%' then 'YN'
else 'CN' or 'BH'
end
)
and SUM_N is not null and SUM_U is not null "; 这种方式没法改吗? else 'CN' 后就是不能加 OR
有啥办法没有?
case
when CODE like '%TW%' then 'YW'
when CODE like '%HK%' then 'YN'
else 'CN' or 'BH'
end
)
and SUM_N is not null and SUM_U is not null ";
这种方式没法改吗? else 'CN' 后就是不能加 OR
有啥办法没有?
if($a=="XXXXXX")
{
$stnt="XXXXXX";
}
else
{
$stnt="BBBBBBB";}
$sqlstr="select*from `product` where ".$stnt;然后在执行..不必要直接生成呀..
我想说的是 最后一句
else 后是不是只能加一个条件?不能加OR
比如
or 'BH'