Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SELECT DISTINCT Cid
from Buysfrom
where Bid in (select Bid
              from Buysfrom
			  where Cid=569
			  And Hrs in(select Hrs 
			             from Buysfrom          
	            where Cid=569);


What I have tried:

try to remove it but error appears in another word
Posted
Updated 11-Dec-22 8:09am
Comments
0x01AA 11-Dec-22 13:40pm    
You miss one closing bracket ')', simply count opening against closing brackets. And on a first glance you don't need two nested select statements.
Richard Deeming 14-Dec-22 6:52am    
Your Hrs in (...) filter doesn't make much sense.

You select a record from the Buysfrom table where Cid=569.

You then check to see if there is a record in the Buysfrom table where Cid=569 and the Hrs column is the same as the current record.

But you know that there is - the current record already matches that condition. The only time you won't get a match is if Hrs is Null.

So your query could be simplified to:
SELECT DISTINCT Cid
FROM Buysfrom
WHERE Bid In 
(
    SELECT DISTINCT Bid
    FROM Buysfrom
    WHERE Cid = 569
    And Hrs Is Not Null
);

1 solution

Count how many opening parenthesis you have and how many closing. There's a mismatch.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900