首页 \ 问答 \ 基于多列删除重复项(Deleting duplicates based on multiple columns)

基于多列删除重复项(Deleting duplicates based on multiple columns)

我使用以下内容列出了重复项:

select s.MessageId, t.* 
from Message s
join (
    select ToUserId, FromUserId, count(*) as qty
    from Message
    group by ToUserId, FromUserId
    having count(*) > 1
) t on s.ToUserId = t.ToUserId and s.FromUserId = t.FromUserId

现在,我该如何删除所有邮件(我试图删除重复邮件,以便在FromUserId and ToUserId上应用唯一索引)。


I have listed duplicates using the following:

select s.MessageId, t.* 
from Message s
join (
    select ToUserId, FromUserId, count(*) as qty
    from Message
    group by ToUserId, FromUserId
    having count(*) > 1
) t on s.ToUserId = t.ToUserId and s.FromUserId = t.FromUserId

Now, how do I delete all but one of the Messages (I'm trying to remove duplicates so I can apply a unique index on FromUserId and ToUserId).


原文:https://stackoverflow.com/questions/41435527
更新时间:2021-09-08 12:09

最满意答案

看到这个问题:

从数据库创建的烧瓶返回图像

您需要设置Content-Type和Content-Disposition标头,以便浏览器知道您要发送的文件类型,并且应该下载而不是显示。


See this question:

flask return image created from database

You need to set the Content-Type and Content-Disposition headers so the browser knows what type of file you're sending, and that it should be downloaded rather than displayed.

相关问答

更多
  • 看到这个问题: 从数据库创建的烧瓶返回图像 您需要设置Content-Type和Content-Disposition标头,以便浏览器知道您要发送的文件类型,并且应该下载而不是显示。 See this question: flask return image created from database You need to set the Content-Type and Content-Disposition headers so the browser knows what type of file ...
  • 您已将url路径/photos/add到回调函数upload_func 。 它看起来像你想支持两种请求类型(GET和POST),然后函数装饰器应该看起来像这样: @route('/photos/add', method=['GET', 'POST']) @jinja_view('add.html') def upload_func(): # ... 看一眼: https://bottlepy.org/docs/dev/tutorial.html#request-routing https://bo ...
  • 我不熟悉Pandas但你需要获取xls文件的二进制内容以通过Bottle路径发送给用户。 Python 3的修改示例: from io import BytesIO from bottle import route, response from pandas import ExcelWriter @route('/get-xlsx') def get_xlsx(): output = BytesIO() writer = ExcelWriter(output, engine='xlsxw ...
  • 你没有发布你的代码,所以我猜它可能会归结为这样的东西: import signal from bottle import route, run def my_handler(*args): print 'in signal handler', args signal.signal(signal.SIGUSR1, my_handler) @route('/hello') def hello(): return "Hello World!\n" run(host='localhost', ...
  • 所以......事情很愚蠢......只要留下答案,以防其他人踩到这个愚蠢的错误...... bottle.route和requests.url需要完全匹配。 在可能的情况下, 路线是api而网址是api/ ...这就是他们不工作的原因...... 一个人需要移动到api/或api 。 So... The thing is pretty silly... Just leaving the answer here in case someone else stomps with this stupid mis ...
  • 好吧,我从来没有想到我要在Stackoverflow上发布的第一个答案是我自己的问题的答案,但我碰巧想出来了,我真的想分享它! 我的第一个问题是我不知道如何在Mongodb数据库中创建第一个用户来测试Cork所具有的功能。 我尝试的第一件事是调用Cork提供的register()方法。 但它引发了异常,因为我没有在数据库中定义任何角色。 因此,我需要先在数据库中创建角色。 我使用了在此链接中找到的代码: https://github.com/FedericoCeratto/bottle-cork/blob/ ...
  • 要在App Engine中提供静态文件,它是最有效的(对您的用户来说更快,如果您通过免费的每日配额,对您来说成本更低)直接从app.yaml这样做 - 只需添加 - url: / static_files: static/index.html 到“catch-all” url: /.*指令之前的app.yaml 。 这样,您的应用程序不会将那些可能正在等待的静态文件请求排在后面,也不需要启动和预热新实例,也不会运行任何代码 - 它只会提供静态文件对于用户来说 ,就像谷歌知道的那样快(包括缓存和类似CD ...
  • 初始代码不起作用,因为您正在返回一个文档,PyMongo将其表示为Python字典。 Flask不知道该怎么做。 (注意,find_one()返回一个文档,find()返回一个Cursor。) 你的最终代码返回它从GridFS.get_last_version()获得的“东西”,它是一个GridOut对象,用于从GridFS文件中读取。 GridOut是可迭代的:迭代GridOut获取块的byes。 Flask 确实知道如何将迭代转换为HTTP响应,因此代码的第二个版本可以工作。 教训是:当您想要与Grid ...
  • 我通常使用以下内容 import bottle from bottle import route, run, template, BaseTemplate, static_file app = bottle.default_app() BaseTemplate.defaults['get_url'] = app.get_url # reference to function @route('/') def index(): return template('mytemplate') @ro ...
  • 我发现Passenger将运行WSGI应用程序。 我按照这篇文章http://kbeezie.com/using-python-nginx-passenger/上的说明操作,并且没有遇到麻烦。 实际上最终很容易。 这是我的适配器,以防其他人遇到麻烦: https://github.com/nick-desteffen/astronomy-pics/blob/master/passenger_wsgi.py I found out that Passenger will run WSGI apps. I fo ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)