zoukankan      html  css  js  c++  java
  • mysql存储过程中like用法

    1. CREATE PROCEDURE `proc_init_tagsData`()  
    2. begin  
    3.   
    4.   DECLARE  v_keyword varchar(30);  
    5.   DECLARE  v_tag_id int default -1;  
    6.   DECLARE  v_done int;  
    7.   DECLARE v_count int default 0;  
    8.   
    9. -- 定义游标  
    10. DECLARE rs_cursor CURSOR FOR select keyword from t_keyword where s_flag=1 order by id limit 15;  
    11.   
    12. DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done=1;  
    13.   
    14. open rs_cursor;  
    15. cursor_loop:loop  
    16.    FETCH rs_cursor into v_keyword; -- 取数据  
    17.   
    18.   
    19.   
    20. if(v_count<15)  then  
    21.   
    22.   insert into t_tag (name)values(v_keyword);  
    23.   
    24.   set v_tag_id = LAST_INSERT_ID();  
    25.   -- 关键是like CONCAT('%',v_keyword,'%'); 这里的用法  
    26.   insert into tbl_sm_tag  (tag_id,soft_id) select v_tag_id,id from sm where soft_name like CONCAT('%',v_keyword,'%');  
    27.   
    28. end if;  
    29.   
    30. set v_count = v_count + 1;  
    31.   
    32.     
    33.   
    34.    if v_done=1 then  
    35.     leave cursor_loop;  
    36.    end if;  
    37.     
    38. end loop cursor_loop;  
    39. close rs_cursor;  
  • 相关阅读:
    函数的声明
    数组遍历的方法
    运算符
    变量命名规则
    js条件判断
    vuex使用
    高盛伦敦分部面试
    野村证券伦敦分部面试
    Linux Performance Monitoring Commands
    Linux server上too many open files问题
  • 原文地址:https://www.cnblogs.com/htys/p/4045738.html
Copyright © 2011-2022 走看看