gpt4 book ai didi

sql - 需要SQL获取一条有两个对应条目的记录

转载 作者:可可西里 更新时间:2023-11-01 07:57:36 27 4
gpt4 key购买 nike

我有一个表格,其中包含对应帐号的详细联系信息:

Contacts_Accounts Tablecontact id | account ID=======================1          | 121          | 131          | 142          | 122          | 133          | 12

我如何创建一个 sql 查询来返回所有同时具有帐号 12 和 13 的条目,例如...我在这里使用 MYSQL

最佳答案

这个嵌套查询应该可以解决问题:

SELECT * FROM Contacts_Accounts where account_ID = 12 and contact_id in (SELECT contact_id from Contacts_Accounts where account_ID = 13)

关于sql - 需要SQL获取一条有两个对应条目的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3253804/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com