去重 数据库_数据库数据怎么去重

去重 数据库_数据库数据怎么去重setnamesutf8;selectcatidfromsupe_categorieswherename=’金融’;得出catid;createtablemultmpselect*fromsupe_spaceitemswherecatidin(selectcatidfromsupe_categorieswherename=’金融’)…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用
set names utf8;

select catid from supe_categories where name=’金融’;

得出catid;

create table multmp select * from supe_spaceitems where catid in(select catid from supe_categories where name=’金融’); 假设上一句的出的catid为1

//以下语句是过滤重复

create table tmpa as select itemid from multmp where subject in(select subject from multmp group by subject having count(itemid)>1);

create table tmpb as select min(itemid) as itemid from multmp group by subject having count(itemid)>1;

create table tmptmp as select itemid from multmp where itemid in (select itemid from tmpa ) and itemid not in (select itemid from tmpb);//要删除的数据的itemid

delete from supe_spacenews where itemid in (select itemid from tmptmp);//删除news

delete from multmp where itemid in (select itemid from tmptmp);

drop table tmpa;

drop table tmpb;

drop table tmptmp;

delete from supe_spaceitems where catid in (select catid from supe_categories where name=’金融’); //删除原表中 catid为1的数据

insert into supe_spaceitems select * from multmp; //将过滤后的数据 添会原表

drop table multmp;//删除中间表

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/187173.html原文链接:https://javaforall.net

(0)
上一篇 2022年10月1日 上午11:16
下一篇 2022年10月1日 上午11:16


相关推荐

  • 初笔,JAVA.HelloWorld代码详解「建议收藏」

    初笔,JAVA.HelloWorld代码详解「建议收藏」HelloWorld.java//文件名publicclassHelloWorld{  publicstaticvoidmain(String[]args){    System.out.println(“HelloWorld!!!”);}}详解:publicclassHelloWorld:class:翻译过来就叫:类,可以理解为是JAVA中一种文件的名字….

    2022年5月28日
    36
  • 迭代器Python_Python进阶

    迭代器Python_Python进阶迭代器迭代是访问集合元素的一种方式。迭代器是一个可以记住遍历的位置的对象。迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束。迭代器只能往前不会后退。可迭代对象我们已经知道可以对l

    2022年7月28日
    7
  • wget找不到命令

    wget找不到命令由于系统中未安装导致,运行yum-yinstallwget 即可;

    2022年5月20日
    50
  • (AI Coding)前端微调神器——Cursor+stagewise

    (AI Coding)前端微调神器——Cursor+stagewise

    2026年3月16日
    3
  • 手把手教你使用R语言做LASSO 回归

    手把手教你使用R语言做LASSO 回归LASSO回归也叫套索回归,是通过生成一个惩罚函数是回归模型中的变量系数进行压缩,达到防止过度拟合,解决严重共线性的问题,LASSO回归最先由英国人RobertTibshirani提出,目前在预测模型中应用非常广泛。在新格兰文献中,有大牛提出,对于变量过多而且变量数较少的模型拟合,首先要考虑使用LASSO惩罚函数。今天我们来讲讲怎么使用R语言通过LASSO回归构造预测模型。首先我们要下载R的glmnet包,由LASSO回归的发明人,斯坦福统计学家TrevorHastie领衔开发。加载

    2022年6月9日
    49
  • rabbitmq高可用集群搭建_mongodb高可用架构

    rabbitmq高可用集群搭建_mongodb高可用架构RabbitMQ高可用集群搭建1集群简介1.1集群架构​ 当单台RabbitMQ服务器的处理消息的能力达到瓶颈时,此时可以通过RabbitMQ集群来进行扩展,从而达到提升吞吐量的目的。RabbitMQ集群是一个或多个节点的逻辑分组,集群中的每个节点都是对等的,每个节点共享所有的用户,虚拟主机,队列,交换器,绑定关系,运行时参数和其他分布式状态等信息。一个高可用,负载均衡的RabbitMQ集群架构应类似下图:这里对上面的集群架构做一下解释说明:​ 首先一个基本的Rabbi

    2025年10月21日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号