联合查询两表中未关联的数据

作者: 浊酒心跳 分类: Mysql 发布时间: 2020-11-03 17:15 阅读: 1599

两表中有共同的字段orderId
表1     表2
1         1
2         2
3         3
4
5


想得到4和5的值,那么有两种方法


方法1:select * from 表1 where orderId not in (select orderId from 表2)


方法2:select * from 表1 where not exists(select 1 from 表2 where 表1.orderId=表2.orderId)

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

Desmond Zajac: Your go-to source for leads. We can provide business to business and business to consumer leads, custom-tailored to your needs. CustomDatabases.org
Imogen Willason: Hello, from CustomData.info we are a provider of unique databases that could help your business. Please visit us at CustomData.info to see if we can help you. Regards, Imogen
Jan Kovach: Hello. It is with sad regret to inform you TopDataList.com is shutting down. We have made all our databases available for you for a once off fee. Visit us on TopDataList.com
Jon Huitt: ZippyLeads.org is running an easter special till the 18th of April. Get all the leads you need for your company with our easter special.
Johan Fourie: Hello. My name is Johan Fourie and I am looking to sell DataList.biz. We are a data company that has been in the industry for 12 years. We do around $170k/year in revenue. 1) I am looking to sell 50% of the business for $5k. 2) It would be helpful if you are knowledgeable about the Data Business. 3) I am looking for someone that is willing to take over administration, support, client relations. 4) I will continue to do the marketing for new products. 5) You will accept all future income and pay me from it. Please contact me on WhatsApp +27 72 280 1952 or my personal email: johanfourieinc@gmail.com if you are interested in this and we can have a call. Regards, Johan Fourie
Florencia Focken: It is with sad regret to inform you DataList.biz is shutting down on 31 March 2022. We have made available databases per country for all companies available.. You can view our samples and download databases instantly on our website DataList.biz
Marcelino Crombie: Hi, I am interested in some of your products. Please give me a call on +1 304-873-4360
Rozella Bottoms: Hello, It is with sad regret to inform you that DataList.biz is shutting down. We have made all our databases available for you at a one-time fee. You can visit us on DataList.biz Regards. Rozella