2016-02-04 64 views
0

0 72十七點37分20秒呼叫new_procedure錯誤代碼:1292截斷不正確 INTEGER值: '_3_ELECTRICITY BILL_3.pdf' 0.140秒截斷不正確INTEGER值而插入到臨時表的MySQL

注意:3_ELECTRICITY BILL_3.pdf值包含tbl_AccountOpeningForm表中AttachmentName

,但如果我從查詢中移除having clause它做工精細。

tbl_AccountOpeningForm 
CustNo   VARCHAR(80) 
AttachmentName VARCHAR(100) 



-- -------------------------------------------------------------------------------- 
-- Routine DDL 
-- Note: comments before and after the routine body will not be stored by the server 
-- -------------------------------------------------------------------------------- 
DELIMITER $$ 

CREATE DEFINER=`root`@`localhost` PROCEDURE `new_procedure`() 
BEGIN 


drop table if exists tblReport; 
create temporary table tblReport 
( 
    CustNo varchar(80) 
) ; 


insert into tblReport (CustNo) 
select CustNo 
from tbl_AccountOpeningForm 
group by CustNo 
having COUNT(case when LTRIM(RTRIM(AttachmentName))='' then null else AttachmentName end)!= 
COUNT(case when LTRIM(RTRIM(AttachmentName))!='' then null else AttachmentName end) limit 10000000; 
select * from tblReport; 


END 

回答

2

嘗試措辭的邏輯是這樣的:

having SUM(LTRIM(RTRIM(AttachmentName)) <> '') <> SUM(LTRIM(RTRIM(AttachmentName)) = '') 
limit 10000000; 

MySQL的通常是相當智能有關從case表達的返回類型。錯誤消息表明它變得困惑。如果這是問題,那麼簡化的邏輯應該修復它。

+0

非常感謝...而且...... Clever @Gordon –

相關問題