2 qq 21525849 qq_21525849 于 2016.03.28 10:20 提问

拼接SQL异常,报错No parameters defined during prepareCall

图片说明
查了一下是SQL中有东西被当做字符串处理了,但找不出哪里问题
大神帮帮我吧

3个回答

qq_21525849
qq_21525849   2016.03.28 10:21

String sql = "SELECT a.*, (CASE WHEN CEIL(IFNULL(b.purchasenum,0)) = 0 " +
"THEN 1 ELSE CEIL(IFNULL(b.purchasenum,0)) END) AS purchasenum FROM " +
"T_AMZFBAPRODUCT a INNER JOIN " +
"(SELECT a.sku,(a.prosnum - IFNULL(b.ordernum,0) - IFNULL(c.deliverynum,0)) AS purchasenum FROM " +
"(SELECT sku, SUM( onedaysn * (15 - savenumendurday) ) AS prosnum FROM T_AMZFBAPRODUCT " +
"WHERE savenumendurday <= 7 GROUP BY sku) a LEFT JOIN " +
"(SELECT productid,SUM(ordernum) AS ordernum FROM T_AMZSMARTPURCHASELOG" +
" WHERE openflag = '1' AND STATUS IN ('1','2','3') GROUP BY productid) b ON a.sku = b.productid LEFT JOIN" +
" (SELECT productid, SUM(deliverynum) AS deliverynum FROM T_AMZTRANSPORTGRPINFO" +
" WHERE grpid IN (SELECT id FROM T_AMZTRANSPORTGROUP WHERE STATUS IN ('新创建','包货中','已发货'))" +
" GROUP BY productid) c ON a.sku = c.productid) b ON a.sku = b.sku";

daidaineteasy
daidaineteasy   Ds   Rxr 2016.03.28 11:46

openflag = '1' AND STATUS IN ('1','2','3') 这里的 openflag 和 STATUS 是字符串类型的么

CSDNXIAOS
CSDNXIAOS   2016.03.30 11:28

语句如下:
 SELECT * FROM TEST WHERE TEST_NAME LIKE '%?%'
修改成
 SELECT * FROM TEST WHERE TEST_NAME LIKE CONCAT('%',?,'%')

即可

concat(var1,var2,.....)mysql中特有的拼接字符串的方式......
答案就在这里:No parameters defined during prepareCall()
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!