首页 新闻 会员 周边 捐助

sql语法问题

-1
悬赏园豆:10 [已关闭问题] 关闭于 2016-03-29 16:07

select d.*,rownum from(
SELECT
rt.outboundkey 出库单号,
(SELECT owner_name FROM bd_owner c WHERE c.owner_code = rt.owner_code AND c.project_code = rt.project_code AND c.whse_code = rt.whse_code AND c.company_code = rt.company_code) 货主,
rt.externorderkey1 客户订单号,
pl.pickkey 拣货单
FROM wh_pick pl left join wh_outbound rt On pl.outboundkey = rt.outboundkey
WHERE 1=1
AND pl.status In ( 'new','part_pick')
${if(len(key) == 0,"","AND pl.pickkey in (" + key + ")")}
and rt.project_code = '${pkey}'
and rt.whse_code = '${wkey}'
order by pl.outboundkey asc)d

谁能告诉我红色那段sql代表的含义,我怎样才能要他语法通过

一v冲天的主页 一v冲天 | 初学一级 | 园豆:106
提问于:2016-03-29 11:10
< >
分享
所有回答(4)
0

${if(len(key) == 0,"","AND pl.pickkey in (" + key + ")")}

你sql语句模板还没替换完

Daniel Cai | 园豆:10424 (专家六级) | 2016-03-29 11:22

什么叫模板没替换完?我问的是${if()}和红色里面的sql代表什么意思

支持(0) 反对(0) 一v冲天 | 园豆:106 (初学一级) | 2016-03-29 11:24
0

if(len(key) != 0则加上AND pl.pickkey in (" + key + ")

 

也就是判断key的长度,如果长度不等于零就要加上这个条件

Rich.T | 园豆:3440 (老鸟四级) | 2016-03-29 11:37
0

这是sql么?红色部分应该是sql模板,需要转换后才能用。

幻天芒 | 园豆:37205 (高人七级) | 2016-03-29 13:21
0

 

1.${if(len(key) == 0,"","AND pl.pickkey in (" + key + ")")}

if(len(key) == 0

   空语句不执行

else

    AND pl.pickkey in (" + key + ") 

2.整体,三个或者四个  and 条件。

AND pl.status In ( 'new','part_pick')
AND pl.pickkey in (" + key + ")")  或没有
and rt.project_code = '${pkey}'
and rt.whse_code = '${wkey}'

小刺猬001 | 园豆:660 (小虾三级) | 2016-03-29 14:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册