CREATE PROCEDURE concatenation()
BEGIN
DECLARE i INT default 1;
declare t varchar(50);
repeat
set @t = concat("INSERT ignore INTO `site_values_" , i , "` (report_time) SELECT CONCAT(", "pcu_rtc_year" , "-" , "pcu_rtc_month" , "-" , "pcu_rtc_day" , " " , "pcu_rtc_hour" , ":" , " pcu_rtc_minute" , ":" , " pcu_rtc_secound",")" ,
" FROM site_values where site_id =" , i);
PREPARE stmt FROM @t;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
set i = i+1;
until i =1001
end repeat;
END;
我有上面的代碼。我可以創建程序。但是,當我把它稱爲 呼叫級聯它顯示存儲過程級聯mysql
"SQLSyntaxError (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ': pcu_rtc_minute: pcu_rtc_secound) FROM site_values where site_id =1' at line 1")"
請告訴我錯我的代碼?
是後'「''字符選擇CONCAT'是否需要? – ramonovski
爲了節省時間,您可以打印出代碼運行時@t的樣子,並更新您的文章? – Tom
pcu_rtc_year等字段名稱? – Tom