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