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

  • 相关阅读:
    Android的各版本间的区别总结
    深入浅出Android开发之Surface介绍
    android中完全退出当前应用程序的四种方法
    android离线地图源码
    坐标系
    mysql安装
    linux磁盘空间清理
    HttpClient教程
    TIME_WAIT过多
    c3p0配置详解
  • 原文地址:https://www.cnblogs.com/fogwang/p/4344475.html
Copyright © 2011-2022 走看看