如何删除另一个表中存在的行? [英] How to remove row that exists in another table?

查看:88
本文介绍了如何删除另一个表中存在的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个桌子.主表是"CompleteEmailListJuly11",第二个表是"CurrentCustomersEmailJuly11".我想删除CurrentCustomersEmailJuly11基于电子邮件的CompleteEmailListJuly11表中的行.

I have two tables. Main table is "CompleteEmailListJuly11" and the second table is "CurrentCustomersEmailJuly11". I want to delete rows in CompleteEmailListJuly11 table that CurrentCustomersEmailJuly11 has based off email.

我已经在下面的Delete示例中尝试过此操作,但是它并没有完成我尝试做的任何事情.这只会向我显示数据库中已存在的电子邮件,而不会显示未匹配的电子邮件列表.

I've tried this following Delete example, but it doesn't do anything close to what I'm trying to do. This only shows me the ones that EXIST in the database, it doesn't show me the the list of emails that AREN'T matching.

DELETE * FROM CompleteEmailListJuly11 AS i 
WHERE EXISTS ( 
    SELECT 1 FROM CurrentCustomersEmailJuly11 
    WHERE CurrentCustomersEmailJuly11.email = i.EmailAddress
)

非常感谢您的帮助.

推荐答案

这是我认为您需要的查询:

This is the query I think you need:

DELETE FROM CompleteEmailListJuly11
WHERE EmailAddress IN (SELECT email FROM CurrentCustomersEmailJuly11)

Ps:DELETE查询不会删除单个字段,而只会删除整个行,因此*不是必需的,您还需要执行"此查询,而不是"Previewing"或"Exporting"

Ps: The DELETE query does not delete individual fields, only entire rows, so the * is not necessary, you will also need to "Execute" this query rather than "Previewing" or "Exporting"

这篇关于如何删除另一个表中存在的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆