1 BEGIN 2 #Routine body goes here... 3 /* 4 update szzx_goods_common set gc_id=i where gc_name=(SELECT gc_name from szzx_goods_class where gc_id=i); 5 */ 6 DECLARE i,goodsid int(11); 7 declare goodsname,img varCHAR(200); 8 set i=104; 9 WHILE i<1815 do 10 SELECT image_url,goods_id into img,goodsid from goods_image where image_id=i; 11 #SELECT goods_id into goodsid from ecm_goods_image where imgage_id=i; 12 SELECT goods_name into goodsname from ecm_goods where goods_id=goodsid; 13 select goods_id into goodsid from szzx_goods where goods_name=goodsname; 14 INSERT into szzx_goods_images(goods_commonid,store_id,goods_image,goods_image_sort)VALUES(goodsid,1,img,1); 15 set i=i+1; 16 17 End WHILE; 18 RETURN 0; 19 ENd
1、在使用使用变量时先定义变量后最下面再赋值。多个变量类型一致,可以用 declare 变量名1,变量名2这样的格式。
2、在函数或过程中用select 语句给变量赋值时,格式应为:select 字段1,字段2 into 变量1,变量2 from 表名 格式
时间: 2024-10-11 12:45:51