gpt4 book ai didi

MySQL:选择问题

转载 作者:可可西里 更新时间:2023-11-01 07:39:29 25 4
gpt4 key购买 nike

有两个表:

wes - contains 8000 rows, with 2000 distinct masternames (mastername is a column in wes)
wem - contains 2100 rows, with 2100 distinct names (name is a column in wem)

我正在尝试获取 wem 中存在的名称,但不是 wes 中的主名称:

SELECT name FROM wem WHERE name NOT IN (SELECT DISTINCT mastername FROM wes)

但出于某种原因,我的查询没有返回任何行,即使 wem 中有大约 100 个名称在 wes 中不作为主名称存在。

有什么问题吗?

谢谢!

最佳答案

您确定子选择中没有 NULLS 吗?

尝试 SELECT mastername FROM wes WHERE mastername IS NULL

如果有,您的查询将返回 0 个 rwow。

调整为:

SELECT NAME FROM wem
WHERE NAME NOT IN (SELECT mastername FROM wes WHERE mastername IS NOT NULL)

关于MySQL:选择问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27313644/

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