标签:one index call begin str cat locate upd while
1 DROP PROCEDURE IF EXISTS w_array; 2 DELIMITER /w/ 3 CREATE PROCEDURE w_array (w_arr VARCHAR(36)) 4 BEGIN 5 WHILE (LOCATE(‘,‘, w_arr) > 0) 6 DO 7 SET @w = LOCATE(‘,‘, w_arr); 8 SET @wtab = SUBSTRING_INDEX(w_arr,‘,‘,1); 9 SET @wtab = CONCAT(‘grab_reviews_‘,@wtab); 10 11 SET @wtmp = CONCAT(‘UPDATE ‘,@wtab,‘ SET asin=exact_asin ‘); 12 PREPARE stmt FROM @wtmp ; 13 EXECUTE stmt ; 14 DROP PREPARE stmt; 15 16 SET w_arr=SUBSTRING(w_arr,@w+1); 17 18 END WHILE; 19 20 SET @wtab = CONCAT(‘grab_reviews_‘,w_arr); 21 SET @wtmp = CONCAT(‘UPDATE ‘,@wtab,‘ SET asin=exact_asin ‘); 22 PREPARE stmt FROM @wtmp ; 23 EXECUTE stmt ; 24 DROP PREPARE stmt; 25 26 END/w/ 27 DELIMITER; 28 CALL w_array(‘us,jp,uk,de,fr,ca,es,it,mx,in‘);
1 <?php 2 $warr = array(‘us‘, ‘jp‘, ‘uk‘, ‘de‘, ‘fr‘, ‘ca‘, ‘es‘, ‘it‘, ‘mx‘, ‘in‘); 3 $sql = ‘UPDATE grab_reviews_‘; 4 $w = ‘‘; 5 foreach ($warr AS $one) { 6 $w .= ‘UPDATE grab_reviews_‘ . $one . ‘ SET asin=exact_asin ; ‘; 7 } 8 echo $w;
1 DROP PROCEDURE IF EXISTS w_array; 2 DELIMITER /w/ 3 CREATE PROCEDURE w_array () 4 BEGIN 5 SET @w_arr = ‘us,jp,uk,de,fr,ca,es,it,mx,in‘; 6 WHILE (LOCATE(‘,‘, @w_arr) > 0) 7 DO 8 SET @w = LOCATE(‘,‘, @w_arr); 9 SET @wtab = SUBSTRING_INDEX(@w_arr,‘,‘,1); 10 SET @wtab = CONCAT(‘grab_reviews_‘,@wtab); 11 12 SET @wtmp = CONCAT(‘UPDATE ‘,@wtab,‘ SET asin=exact_asin ‘); 13 PREPARE stmt FROM @wtmp ; 14 EXECUTE stmt ; 15 DROP PREPARE stmt; 16 17 SET @w_arr=SUBSTRING(@w_arr,@w+1); 18 19 END WHILE; 20 21 SET @wtab = CONCAT(‘grab_reviews_‘,@w_arr); 22 SET @wtmp = CONCAT(‘UPDATE ‘,@wtab,‘ SET asin=exact_asin ‘); 23 PREPARE stmt FROM @wtmp ; 24 EXECUTE stmt ; 25 DROP PREPARE stmt; 26 27 END/w/ 28 DELIMITER; 29 CALL w_array;
WHICH ONE IS BETTER FOR NEWBIE?
标签:one index call begin str cat locate upd while
原文地址:http://www.cnblogs.com/yuanjiangw/p/6284019.html