UNION DISTINCT
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的更多相关文章
- UNION并集运算
在集合论中,两个集合(集合A和集合B)的并集是一个包含集合A和B中所有元素的集合.换句话说,如果一个元素属于任何一个输入集合,那么它也属于结果集.如图所示.
- sql注入绕过union select过滤
# # # #WAF Bypassing Strings: /*!%55NiOn*/ /*!%53eLEct*/ ,,)-- - +union+distinct+select+ +union+dist ...
- MySQL学习(五) UNION与UNION ALL
UNION用于把来自许多SELECT语句的结果组合到一个结果集合中,也叫联合查询. SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | ...
- UNION WHERE
w条件语句的作用域. SELECT * FROM ( SELECT asin, LOWER(country) AS country FROM grab_amzreviews_asins UNION D ...
- UNION(并集)集合运算
在集合论中,两个集合(记为集合A和B)的并集是一个包含集合A和B中所有元素的集合.换句话说,如果一个元素属于任何一个输入集合,那么它也属于结果集. 在T-SQL中,UNION 集合运算可以将两个输入查 ...
- MySQL UNION 查询
UNION 用来合并多个 SELECT 结果. 考察如下两个表: # t1 +----+---------+ | id | pattern | +----+---------+ | 1 | Divot ...
- mysql语法之union
UNION的语法结构: SELECT ... UNION [ ALL | DISTINCT ] SELECT .... [ UNION [ ALL | DISTINCT ] SELECT ..... ...
- mysql中的union操作(整理)
mysql中的union操作(整理) 一.总结 一句话总结: union两侧的字段数和字段类型要是一样的 union可以接多个 orderby和排序可以在最后的union组合之后 1.union简单实 ...
- MySQL SELECT语法(四)UNION语法详解
源自MySQL 5.7 官方手册:13.2.9.3 UNION Syntax 一.UNION语法 UNION用于将多个SELECT语句的结果合并到一个结果集中. SELECT ... UNION [A ...
随机推荐
- [转] James A. whittaker:经营成功的测试生涯
James A. whittaker:经营成功的测试生涯 2015-05-13 James Whittaker James Whittaker is an energetic and passiona ...
- Jquery 事件执行两次
js(jquery)的on绑定点击事件执行两次的解决办法—不是事件绑定而是事件冒泡 阻止冒泡的方法并不止 return false 这一种,还有event.stopPropagation(),这两种方 ...
- java服务端json结果集传值给前端的数据输出格式
在服务端输出json数据时按照一定的格式输出时间字段,fastjson支持两种方式:1.使用JSON.toJSONStringWithDateFormat方法2.JSON.toJSONString方法 ...
- systemd启动多实例
最近用了centos7,启动管理器用的是systemd,感觉很好玩. 1.开机自动启动 新建一个service文件放到/usr/lib/systemd/system/ 比如: [Unit] Descr ...
- [Linux内核]ctrl-z/fg/bg/nohup/setsid/()与&/disown/screen
转自:https://my.oschina.net/alphajay/blog/65058 My Tips: Ctrl -z -> suspend fg -> ...
- linux 链接的使用 创建和删除符号连接(软、硬链接)
1 . 使用方式 :ln [option] source_file dist_file (source_file是待建立链接文件的文件,dist_file是新创建的链接文件) ...
- 随机算法 - HNU 13348 Finding Lines
Finding Lines Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13348&am ...
- Android 性能测试之TraceView的使用
Traceview是android平台配备一个很好的性能分析的工具.它可以通过图形化的方式让我们了解我们要跟踪的程序的性能,并且能具体到method. 在SDK路径\tools目录下. 1.在开始使用 ...
- 关于Unity的组件和作用
一.Transform组件 整个场景由节点树组成. 节点+Transform组件,每个Transform有自己的孩子Transform,由Transform组成Transform树,而每个Transf ...
- 匿名内部类 Inner class
先说结论 匿名内部类分两种,一种是接口的匿名实现,一种是类的匿名子类!后者往往用于修改特定方法. 再说起因 本来以为匿名内部类很简单,就是接口的匿名实现,直到我发现了下面这段代码: public cl ...