简体   繁体   中英

Query returning wrong result, one row is expected but getting ALL

My statement below is returning all the results of the table instead of only with matching n1. I have attached the screenshot of the result. What I am expecting is just the first row. Can someone help me understand what is taking place here please? 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);

This query you have now checks whether value "n1" exists in table proj_d. Which is always true. So I guess you want something like this:

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

But you could do this right away without using a subquery:

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

But probably you need to give more information what you want exactly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM