w同结构表读写合并。

 DROP PROCEDURE IF EXISTS w_ww_amzasin;
DELIMITER /w/
CREATE PROCEDURE w_ww_amzasin()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE w_asin VARCHAR(16);
DECLARE w_country VARCHAR(6);
DECLARE wcur CURSOR FOR
SELECT asin,country FROM grab_amzreviews_asins
UNION DISTINCT
SELECT asin,country FROM grab_amzsimilar_seller_asins
UNION DISTINCT
SELECT asin,country FROM grab_amzlisting
WHERE CONCAT(asin,LOWER(country)) NOT IN
(SELECT CONCAT(asin,LOWER(country)) FROM amzasin) ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN wcur;
read_loop: LOOP
FETCH wcur INTO w_asin,w_country;
IF done THEN LEAVE read_loop;
END IF;
SET @w_nothhtps='www.amazon.';
SET @w_most=CONCAT(LOWER(w_country),'/product/dp/',w_asin);
CASE LOWER(w_country)
WHEN 'ca' THEN SELECT 'w';
WHEN 'in' THEN SELECT 'w';
WHEN 'es' THEN SELECT 'w';
WHEN 'it' THEN SELECT 'w';
WHEN 'fr' THEN SELECT 'w'; WHEN 'jp' THEN SET @w_most=CONCAT('co.',@w_most);
WHEN 'uk' THEN SET @w_most=CONCAT('co.',@w_most); WHEN 'mx' THEN SET @w_most=CONCAT('com.',@w_most); WHEN 'us' THEN SET @w_most=CONCAT('com/gp/product/',w_asin);
ELSE
BEGIN
END;
END CASE; SET @w_nothhtps=CONCAT(@w_nothhtps,@w_most);
SET @wtmp = CONCAT('INSERT INTO amzasin (asin,country,url) VALUES ( "',w_asin,'","',w_country,'","',@w_nothhtps,'")');
PREPARE stmt FROM @wtmp ;
EXECUTE stmt ;
DROP PREPARE stmt;
END LOOP;
CLOSE wcur;
END/w/
DELIMITER;
CALL w_ww_amzasin( ); DROP PROCEDURE IF EXISTS w_ww_amzasin;
DELIMITER /w/
CREATE PROCEDURE w_ww_amzasin()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE w_asin VARCHAR(16);
DECLARE w_country VARCHAR(6);
DECLARE wcur CURSOR FOR SELECT asin,country FROM grab_amzlisting WHERE CONCAT(asin,LOWER(country)) NOT IN (SELECT CONCAT(asin,LOWER(country)) FROM amzasin );
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN wcur;
read_loop: LOOP
FETCH wcur INTO w_asin,w_country;
IF done THEN LEAVE read_loop;
END IF;
SET @w_nothhtps='www.amazon.';
SET @w_most=CONCAT(LOWER(w_country),'/product/dp/',w_asin);
CASE LOWER(w_country)
WHEN 'ca' THEN SELECT 'w';
WHEN 'in' THEN SELECT 'w';
WHEN 'es' THEN SELECT 'w';
WHEN 'it' THEN SELECT 'w';
WHEN 'fr' THEN SELECT 'w'; WHEN 'jp' THEN SET @w_most=CONCAT('co.',@w_most);
WHEN 'uk' THEN SET @w_most=CONCAT('co.',@w_most); WHEN 'mx' THEN SET @w_most=CONCAT('com.',@w_most); WHEN 'us' THEN SET @w_most=CONCAT('com/gp/product/',w_asin);
ELSE
BEGIN
END;
END CASE; SET @w_nothhtps=CONCAT(@w_nothhtps,@w_most);
SET @wtmp = CONCAT('INSERT INTO amzasin (asin,country,url) VALUES ( "',w_asin,'","',w_country,'","',@w_nothhtps,'")');
PREPARE stmt FROM @wtmp ;
EXECUTE stmt ;
DROP PREPARE stmt;
END LOOP;
CLOSE wcur;
END/w/
DELIMITER;
CALL w_ww_amzasin( ); DROP PROCEDURE IF EXISTS w_ww_amzasin;
DELIMITER /w/
CREATE PROCEDURE w_ww_amzasin()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE w_asin VARCHAR(16);
DECLARE w_country VARCHAR(6);
DECLARE wcur CURSOR FOR SELECT asin,country FROM grab_amzsimilar_seller_asins WHERE CONCAT(asin,LOWER(country)) NOT IN (SELECT CONCAT(asin,LOWER(country)) FROM amzasin );
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN wcur;
read_loop: LOOP
FETCH wcur INTO w_asin,w_country;
IF done THEN LEAVE read_loop;
END IF;
SET @w_nothhtps='www.amazon.';
SET @w_most=CONCAT(LOWER(w_country),'/product/dp/',w_asin);
CASE LOWER(w_country)
WHEN 'ca' THEN SELECT 'w';
WHEN 'in' THEN SELECT 'w';
WHEN 'es' THEN SELECT 'w';
WHEN 'it' THEN SELECT 'w';
WHEN 'fr' THEN SELECT 'w'; WHEN 'jp' THEN SET @w_most=CONCAT('co.',@w_most);
WHEN 'uk' THEN SET @w_most=CONCAT('co.',@w_most); WHEN 'mx' THEN SET @w_most=CONCAT('com.',@w_most); WHEN 'us' THEN SET @w_most=CONCAT('com/gp/product/',w_asin);
ELSE
BEGIN
END;
END CASE; SET @w_nothhtps=CONCAT(@w_nothhtps,@w_most);
SET @wtmp = CONCAT('INSERT INTO amzasin (asin,country,url) VALUES ( "',w_asin,'","',w_country,'","',@w_nothhtps,'")');
PREPARE stmt FROM @wtmp ;
EXECUTE stmt ;
DROP PREPARE stmt;
END LOOP;
CLOSE wcur;
END/w/
DELIMITER;
CALL w_ww_amzasin( ); DROP PROCEDURE IF EXISTS w_ww_amzasin;
DELIMITER /w/
CREATE PROCEDURE w_ww_amzasin()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE w_asin VARCHAR(16);
DECLARE w_country VARCHAR(6);
DECLARE wcur CURSOR FOR SELECT asin,country FROM grab_amzreviews_asins WHERE CONCAT(asin,LOWER(country)) NOT IN (SELECT CONCAT(asin,LOWER(country)) FROM amzasin );
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN wcur;
read_loop: LOOP
FETCH wcur INTO w_asin,w_country;
IF done THEN LEAVE read_loop;
END IF;
SET @w_nothhtps='www.amazon.';
SET @w_most=CONCAT(LOWER(w_country),'/product/dp/',w_asin);
CASE LOWER(w_country)
WHEN 'ca' THEN SELECT 'w';
WHEN 'in' THEN SELECT 'w';
WHEN 'es' THEN SELECT 'w';
WHEN 'it' THEN SELECT 'w';
WHEN 'fr' THEN SELECT 'w'; WHEN 'jp' THEN SET @w_most=CONCAT('co.',@w_most);
WHEN 'uk' THEN SET @w_most=CONCAT('co.',@w_most); WHEN 'mx' THEN SET @w_most=CONCAT('com.',@w_most); WHEN 'us' THEN SET @w_most=CONCAT('com/gp/product/',w_asin);
ELSE
BEGIN
END;
END CASE; SET @w_nothhtps=CONCAT(@w_nothhtps,@w_most);
SET @wtmp = CONCAT('INSERT INTO amzasin (asin,country,url) VALUES ( "',w_asin,'","',w_country,'","',@w_nothhtps,'")');
PREPARE stmt FROM @wtmp ;
EXECUTE stmt ;
DROP PREPARE stmt;
END LOOP;
CLOSE wcur;
END/w/
DELIMITER;
CALL w_ww_amzasin( );

UNION DISTINCT的更多相关文章

  1. UNION并集运算

    在集合论中,两个集合(集合A和集合B)的并集是一个包含集合A和B中所有元素的集合.换句话说,如果一个元素属于任何一个输入集合,那么它也属于结果集.如图所示.

  2. sql注入绕过union select过滤

    # # # #WAF Bypassing Strings: /*!%55NiOn*/ /*!%53eLEct*/ ,,)-- - +union+distinct+select+ +union+dist ...

  3. MySQL学习(五) UNION与UNION ALL

    UNION用于把来自许多SELECT语句的结果组合到一个结果集合中,也叫联合查询. SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | ...

  4. UNION WHERE

    w条件语句的作用域. SELECT * FROM ( SELECT asin, LOWER(country) AS country FROM grab_amzreviews_asins UNION D ...

  5. UNION(并集)集合运算

    在集合论中,两个集合(记为集合A和B)的并集是一个包含集合A和B中所有元素的集合.换句话说,如果一个元素属于任何一个输入集合,那么它也属于结果集. 在T-SQL中,UNION 集合运算可以将两个输入查 ...

  6. MySQL UNION 查询

    UNION 用来合并多个 SELECT 结果. 考察如下两个表: # t1 +----+---------+ | id | pattern | +----+---------+ | 1 | Divot ...

  7. mysql语法之union

    UNION的语法结构: SELECT ... UNION [ ALL | DISTINCT ]  SELECT .... [ UNION [ ALL | DISTINCT ] SELECT ..... ...

  8. mysql中的union操作(整理)

    mysql中的union操作(整理) 一.总结 一句话总结: union两侧的字段数和字段类型要是一样的 union可以接多个 orderby和排序可以在最后的union组合之后 1.union简单实 ...

  9. MySQL SELECT语法(四)UNION语法详解

    源自MySQL 5.7 官方手册:13.2.9.3 UNION Syntax 一.UNION语法 UNION用于将多个SELECT语句的结果合并到一个结果集中. SELECT ... UNION [A ...

随机推荐

  1. forward declaration of class 错误

    在使用Qt的时候遇到这个错误,查了一下发现,是因为我没有正确的使用前置声明. #ifndef FIRSTPAGE_H #define FIRSTPAGE_H #include "ui_dia ...

  2. 在sql中根据成绩显示学生排名

    1.准备 create table newtable ( name ), yuwen ), shuxue ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; , ); , ...

  3. python walk函数

    os.walk方法 import os for i in os.walk(r'C:\Users\jack\Desktop\test\3_语文语文版七年级上册\1_一单元'): print(i[0]) ...

  4. cocos2dx场景切换的坑

    有一个类可以使用不同的数据源,每个数据源对应一个对象. 我在类里保存了对象的实例,由于要在其它地方使用所以做成了静态,并在每次初始化时 重新设置,析构时删除. 现在我打开了A,切换到B,结果这个静态的 ...

  5. cocos2d-x中CCEditbox导出到lua

    自从工作后感觉时间较少(每天工作9-22,晚上就不想动了,早上想多睡点),工作中用的是 cocos2d-x.cocos2d-x是一款手机游戏引擎,虽然支持lua,但和love2d相比非纯lua游戏引 ...

  6. [Linux内核]软中断、tasklet、工作队列

    转自:http://www.cnblogs.com/li-hao/archive/2012/01/12/2321084.html 软中断.tasklet和工作队列并不是Linux内核中一直存在的机制, ...

  7. hdu6143 Killer Names 容斥+排列组合

    /** 题目:hdu6143 Killer Names 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6143 题意:有m种字符(可以不用完),组成两个长度 ...

  8. 使用导出导入(datapump)方式将普通表切换为分区表

    随着数据库数据量的不断增长,有些表须要由普通的堆表转换为分区表的模式. 有几种不同的方法来对此进行操作,诸如导出表数据,然后创建分区表再导入数据到分区表:使用EXCHANGE PARTITION方式来 ...

  9. multimap 小例子

    场景: 按DDX值倒序取前十的板块代码,用 map<float, string, greater<float> > mapBKDDX; 存储时,相同DDX值的板块只能存储第一个 ...

  10. 有关Servlet的生命周期说法正确的有( )。

    A.Servlet的生命周期由Servlet实例控制 B.init()方法在创建完Servlet实例后对其进行初始化,传递的参数为实现ServletContext接口的对象 C.service()方法 ...