paip.输入法编程---带ord gudin去重复-

时间:2022-04-04 02:18:23

paip.输入法编程---带ord gudin去重复-

作者Attilax ,  EMAIL:1466519819@qq.com
来源:attilax的专栏
地址:http://blog.csdn.net/attilax

--------查询重复(不同ORD)

SELECT
 hezi,
 atian,
 gudin,
 
 count(id) AS num
FROM
 gaopinzi
WHERE
 LENGTH(atian) > 0 and   ( del is null    or del=0)  and lang='chinese'
GROUP BY
 hezi,
 atian
 
HAVING
 num > 1

-----------加入临时表.

DELETE from tmp_tsiku;
 
insert tmp_tsiku(hezi,atian,gudin,lang)

SELECT
 hezi,
 atian,
 gudin,
 
 count(id) AS num
FROM
 gaopinzi
WHERE
 LENGTH(atian) > 0 and   ( del is null    or del=0)  and lang='chinese'
GROUP BY
 hezi,
 atian
 
HAVING
 num > 1
;
select *   from tmp_tsiku

去重复存储过程 conf_del
----------------------
原理如下:
for( tmp_tsiku )
if(getTsityao_count(hezi,py))
{
baolyeu_id=  get_top1(hezi,py);
del_other(hezi,py,baolyeu_id);

}

BEGIN
 #Routine body goes here...
declare tmpName varchar(200) default '' ;
declare var_ati varchar(200) default '' ;
  declare havgudin int;
  declare gundi_id int;
  declare rownum int;
  declare tsityao_count int;
  declare baolyeu_id int;

declare tmpint int;
DECLARE isRecordNotFound int;
 
 declare cur1 CURSOR FOR   select hezi,atian from tmp_tsiku where 1=1   ;
declare continue handler for not found set isRecordNotFound = 1;
-- Oracle的PL/SQL的指针有个隐性变量%notfound,
       -- Mysql是通过一个Error handler的声明来进行判断的,
       -- declare continue handler for Not found (do some action);
       -- 在Mysql里当游标遍历溢出时,会出现一个预定义的NOT FOUND的Error,
       -- 我们处理这个Error并定义一个continue的handler就可以了
    -- 下面一句不能没有,否则将会进不了while循环
       set isRecordNotFound = 0;
set rownum=1;
  /*开游标*/
#set tmpName=; set  var_ati
     OPEN cur1;

/*游标向下走一步*/

FETCH cur1 INTO tmpName,var_ati;

/* 循环体 这很明显 把游标查询出的 name 都加起并用 ; 号隔开 */

WHILE ( isRecordNotFound = 0 ) DO

set tsityao_count=getTsityao_count(tmpName,var_ati);
       if tsityao_count>1 THEN
          
          select havgudin,rownum ;
         
             set

baolyeu_id=    get_top1(tmpName,var_ati);

select  gundi_id,rownum ;
             set

tmpint=  del_other(tmpName,var_ati,baolyeu_id);

end if;

set rownum=rownum+1;
/*yao jya jeig select ,beri zweiheu yg result b show chwlai.. */
select 'the end';
      /*游标向下走一步*/

FETCH cur1 INTO tmpName,var_ati;

END WHILE;

CLOSE cur1;

END

-------getTsityao_count---------
BEGIN
 #Routine body goes here...
DECLARE gudinid int ;

set @gudinid=  (

SELECT
  COUNT(*)
FROM
 gaopinzi
WHERE
 
  (del IS NULL OR del = 0)
AND lang = 'chinese'
AND hezi = hezi
AND atian =py

);
 RETURN @gudinid;
END
--------get_top1-----------
BEGIN
 #Routine body goes here...
DECLARE gudinid int ;

set @gudinid=  ( select  id from gaopinzi   where lang='chinese'  and HEZI=hezix and ATIAN=py

and (del is null or del=0)
 
order by gudin desc,ord,id
limit 1

);
 RETURN @gudinid;
END

---------del_other---------
BEGIN
 #Routine body goes here...
#select SQL_NO_CACHE  del_no_gudin ('一','y',3192) c1

declare tmpName INT;
 
/*
update  gaopinzi set del=1,deltime=now(),dely='del no-gudin' 
*/
 #SET NAMES 'utf8';
insert tmp(id,hezi,py) 
 
select id,hezi,atian from gaopinzi

where lang='chinese'  and HEZI=hezix and atian=py
and  ( del is null    or del=0)  
 and id!=baolyeuid

;
 RETURN  tmpName;

END

检查得到的tmp是否OK.
-----------

触发器日志
---------
以便进行误删除恢复..
CREATE TRIGGER `deladdtime` AFTER UPDATE ON `gaopinzi` FOR EACH ROW begin
 
insert  logx(idop,eventx,timex,demo,hezi,pyold,pynew)values( old.id,'update rec',now(),'',old.hezi,old.atian,new.atian);
end;

删除虫复
-----------
update  gaopinzi set del=1,deltime=now(),dely='del no-gudin'  
where id in (select id from tmp)

----------恢复误删除的记录

select * from logx WHERE id>=6 and id<=10
 (select idop from logx WHERE id>=6 and id<=10);
select * from gaopinzi  where id in (13083,15319,15736,16030,137815);
UPDATE gaopinzi set del=0,deltime=now(),dely='hweif' where id in (13083,15319,15736,16030,137815);
select * from gaopinzi where id=137815

------------------已下为测试SQL--------------
------------------已下为测试SQL--------------

select * from gaopinzi   where lang='chinese'  and HEZI='七' and ( del is null    or del=0) order by id

limit 7;
select  * from gaopinzi   where lang='chinese'  and HEZI='一'  and ( del is null    or del=0)
exec QUERY_chonf_nosame_ord

-----查询是否有重复的记录...

SELECT
  COUNT(*)
FROM
 gaopinzi
WHERE
 LENGTH(hezi) = 3
AND (del IS NULL OR del = 0)
AND lang = 'chinese'
AND hezi = '针'
AND atian = 'jenjs'
ORDER BY
 gudin DESC,
 ord

-------得到要保留的ID
SELECT
 *
FROM
 gaopinzi
WHERE
 LENGTH(hezi) = 3
AND (del IS NULL OR del = 0)
AND lang = 'chinese'
AND hezi = '针'
AND atian = 'jenjs'
ORDER BY
 gudin DESC,
 ord
LIMIT 1

------删除其他记录.

update  gaopinzi set del=1  where
LENGTH(hezi) = 3
AND (del IS NULL OR del = 0)
AND lang = 'chinese'
AND hezi = '针'
AND atian = 'jenjs'
and id!=@top1

select * from gaopinzi

where lang='chinese'  and HEZI='一' and atian='y'
and  ( del is null    or del=0)  
and gudin=0 and id!=3192

=============

update gaopinzi  set del=1 ,dely='test' where id=7106 and atian='cy'
update gaopinzi  set del=1 ,dely='test' where id=7106 and atian='cy'
select * from   gaopinzi    where id=7106

select * from  tmp

select hezi,atian from   gaopinzi  where lang='chinese'   and (del is null or del=0)  and LENGTH(hezi)=3

and ord=99   order by hezi

select * from gaopinzi   where lang='chinese'   and (del is null or del=0)  and LENGTH(hezi)=3  and ord=99

order by hezi

select havgudin('针','jen')

select havgudin('一','y')

paip.输入法编程---带ord gudin去重复-的更多相关文章

  1. paip&period;输入法编程----删除双字词简拼

    paip.输入法编程----删除双字词简拼 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/at ...

  2. paip&period;输入法编程---增加码表类型

    paip.输入法编程---增加码表类型 作者Attilax ,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net/attil ...

  3. paip输入法编程之生活用高频字,以及汉字分级

    paip输入法编程之生活用高频字 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/attilax ...

  4. paip&period;输入法编程----一级汉字1000个

    paip.输入法编程----一级汉字1000个.txt 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn. ...

  5. paip&period;输入法编程---输入法ATIaN历史记录 c823

    paip.输入法编程---输入法ATIaN历史记录 c823 作者Attilax ,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csd ...

  6. paip&period;输入法编程--英文ati化By音标原理与中文atiEn处理流程 python 代码为例

    paip.输入法编程--英文ati化By音标原理与中文atiEn处理流程 python 代码为例 #---目标 1. en vs enPHati 2.en vs enPhAtiSmp 3.cn vs ...

  7. paip&period;输入法编程---词库多意义条目分割 python实现&period;

    paip.输入法编程---词库多意义条目分割 python实现. ==========子标题 python mysql 数据库操作 多字符分隔,字符串分割 字符列表循环  作者 老哇的爪子 Attil ...

  8. paip&period;输入法编程---词频顺序order by py

    paip.输入法编程---词频顺序order by py 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn ...

  9. paip&period;输入法编程---智能动态上屏码儿长调整--&period;txt

    paip.输入法编程---智能动态上屏码儿长调整--.txt 作者Attilax ,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csd ...

随机推荐

  1. Collection集合

    一些关于集合内部算法可以查阅这篇文章<容器类总结>. (Abstract+) Collection 子类:List,Queue,Set 增: add(E):boolean addAll(C ...

  2. eclipse 导入工程报错Unable to execute dex&colon; Multiple dex files define Landroid&sol;annotation&sol;SuppressLint

    对策: 检查libs 是否有重复加载的.

  3. 新旧各版本的MySQL可以从这里下载

    http://downloads.mysql.com/archives/

  4. 以http形式启动uwsgi服务

    uwsgi yourfile.ini # 配置文件 [uwsgi] http = 127.0.0.1:3106 socket = 127.0.0.1:3006 chdir = /www/student ...

  5. CF 8D Two Friends &lpar;三分&plus;二分&rpar;

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题意 :有三个点,p0,p1,p2.有两个人ali ...

  6. Problem A

    Problem A Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Sub ...

  7. 写好的Java代码在命令窗口运行——总结

    步骤: 1.快捷键 win+r,在窗口中输入cmd,enter键进入DOS窗口. 2.假设写好的代码的目录为:D:\ACM 在DOS中依次写入:cd d: cd ACM 利用cd切换到代码文件所在的目 ...

  8. python3&period;7新增关键字:async、await;带来和kafka-python&equals;&equals;1&period;4&period;2的兼容性问题

    python3.7新增关键字:async.await: kafka-python==1.4.2用到了关键字async,由此带来兼容性问题 解决方案: 升级kafka-python==1.4.4 使用p ...

  9. 秒杀多线程第六篇 经典线程同步 事件Event

    原文地址:http://blog.csdn.net/morewindows/article/details/7445233 上一篇中使用关键段来解决经典的多线程同步互斥问题,由于关键段的“线程所有权” ...

  10. 远程复制数据免登录 rsync 和 scp

    一.备用机上(用于存放备份的机器)  和 目标机上(需要备份的服务器 ,如 246) 都需要安装 :   yum install -y rsync 二.备用机上运行命令: -t rsa Generat ...