gpt4 book ai didi

sql - PostgreSQL 查询选择除这些以外的所有

转载 作者:行者123 更新时间:2023-11-29 14:19:59 25 4
gpt4 key购买 nike

A

reference, row, count, etc...

B

reference, row, xxx, etc...

如何从表 B 中获取所有在 A 中带有 reference 的记录,排除带有 row B?

select "reference", "row", "count", "xxx" 
from B
where A.reference = B.reference and A.row != B.row

最佳答案

也许这就是你想要的?

select b."reference", b."row", a."count", b."xxx" 
from b
join a on a."reference" = b."reference"
where a."row" not in (select "row" from b)

这将从 B 中选择在 A 中具有匹配“reference”的所有行,但是 A.“row”不存在于 B< 中的“row”值中.

关于sql - PostgreSQL 查询选择除这些以外的所有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32184395/

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