zoukankan      html  css  js  c++  java
  • mysql自定义函数与过程中写法的注意事项

     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 表名 格式

  • 相关阅读:
    Java中的pom.xml
    Java中request请求配置
    java,名称工具类。手机号加星。
    Java数据库查询与循环处理
    php接口分页
    java中sql映射机制
    java中的model映射
    Java启动项目
    httpSession.removeAttribute 移除header中的属性
    mybatisplus 查询数据
  • 原文地址:https://www.cnblogs.com/fogwang/p/4344475.html
Copyright © 2011-2022 走看看