查询返回错误的结果,需要一行,但得到全部

zqdjd7g9  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(284)

我下面的语句将返回表的所有结果,而不是仅返回匹配的n1。我附上了结果的截图。我期待的只是第一排。有人能帮我理解这里发生了什么吗?所附查询结果

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

m1m5dgzv1#

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'

但也许你需要提供更多你想要的信息

相关问题