Click here to Skip to main content
15,893,923 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
Hello to all.


I have two tables
* UsersPoints(Column- UserName , Points)
* PrizeGiven(Column- UserName , Points)


suppose i want to give prize to those users who have >100 points ( from table UserPoints) and then i will insert that username and 100 Points in PrizeGiven Table so that i can remove this user in future prise distribution( i am not removing this user and points from UserPoints Table).


"(select UserName from UsersPoints where Points >100) WHERE UserName NOT IN (select UserName from PrizeGiven where Points=100)"


But query is not working !!!
Posted

1 solution

You made an error in the SQL syntax.

SQL
SELECT up.UserName 
FROM UsersPoints up 
WHERE 
    up.Points >100 AND 
    up.UserName NOT IN 
        (SELECT pg.UserName 
         FROM PrizeGiven pg 
         WHERE pg.Points=100
        )


Regards,

Manfred
 
Share this answer
 
Comments
Pr!y@ 6-May-12 18:53pm    
Thankyou Very Much ....
Manfred Rudolf Bihy 7-May-12 2:16am    
You're welcome, come back anytime!
Pr!y@ 8-May-12 12:45pm    
Sir it is not working ..............!!!!!

SELECT up.UserName, up.Points
FROM UsersPoints up
WHERE
up.Points >100 AND
up.UserName NOT IN
(SELECT pg.UserName
FROM PrizeGiven pg
WHERE pg.Points=100
)


Your Previous answer is right but when i select points also it is not working !!!

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