gpt4 book ai didi

mysql - 查询返回错误结果,预期一行但得到全部

转载 作者:行者123 更新时间:2023-11-29 06:49:03 25 4
gpt4 key购买 nike

我下面的语句返回表的所有结果,而不是仅返回匹配的 n1。我已附上结果的屏幕截图。我所期待的只是第一行。有人可以帮助我了解这里发生了什么吗? Result of the Query attached

Create View Proj_Display AS
select * from Proj_d
Where "n" in (Select Student from proj_d);

最佳答案

Create View Proj_Display AS
select * from Proj_d
Where "n1" in (Select Student from proj_d);

您现在的查询检查表 proj_d 中是否存在值“n1”。这始终是正确的。所以我猜你想要这样的东西:

Create View Proj_Display AS
select * from Proj_d
Where Student in (Select Student from proj_d WHERE Student = 'n1');

但是您可以立即执行此操作,而无需使用子查询:

Create View Proj_Display AS
select * from Proj_d
Where Student = 'n1'

但是您可能需要提供更多您想要的信息

关于mysql - 查询返回错误结果,预期一行但得到全部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48229426/

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