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 ...
随机推荐
- android自定义控件(1)-自定义控件属性
那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...
- Nokia Imaging SDK滤镜使用入门
简要说明: 通过对示例图片分别运用 LomoFilter和SketchFilter两个滤镜(Nokia Imaging SDK 内置), 来学习滤镜的基本使用和参数的设置.本工程的代码量比较少,也很容 ...
- [转]T-SQL_面试题
[转]T-SQL_面试题 2015-05-19 1 创建表插入数据 Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,s ...
- Qt5中的QtGui
我在学习Qt查看Qt Creater提供的例子时,遇到了一个小问题.就是明明在代码中包含了QtGui,然而编译的时候还是提示找不到QLabel的定义,以及其他一些类的定义,但是这是官方提供的文档的啊, ...
- [I2C]pca9555应用层测试代码
注意点: 如果在设置I2C_SLAVE的时候,提示device_busy,可以使用I2C_SLAVE_FORCE, 在驱动里面二者对应同一个case语句 应用层可以调用接口:i2c_smbus_wri ...
- Spring Boot - can't start with embedded tomcat error
com.fasterxml.jackson.core版本问题,更新最新版本即可. I had the same problem, it seems that: <dependency> & ...
- 本机添加多个git仓库账号
我们可能会需要在一台电脑上以不同的github账户去使用git,这时就需要去解决如何管理本机上的多个ssh key的问题了. 生成新ssh key 如果我们电脑上已经存在了一个ssh key,那么我们 ...
- python文件编码说明 coding=utf-8
python 支持3种编码声明,一般常用能见到下面两种 1.# -*- coding: utf-8 -*- 这种写法是为了兼容Emacs的编码声明 2.短一点,但Emacs不能用# coding=ut ...
- CI 如何获取get请求过来的数据
http://localhost/ci_tuangou/index.php/home/index/index?gid=2 echo 'gid='. $this->input->get('g ...
- 【BZOJ】1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛(lis)
http://www.lydsy.com/JudgeOnline/problem.php?id=1669 水题太严重 #include <cstdio> #include <cstr ...