Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help with select

Author  Topic 

lucsky8
Posting Yak Master

105 Posts

Posted - 2010-02-24 : 08:45:39
Hi, i have 2 tables
-tblEleves
-tblM2EvaluationElementReponse

I need to select all the student event if they don't anything yet in the table tblM2EvaluationElementReponse

Something like this :
SELECT     te.intEleveId,te.strNom,te.strPrenom,ter.intEvaluationElementId,ter.strNote
FROM tblEleves as te
left JOIN tblM2EvaluationElementReponse as ter
ON ter.intElevesId = te.intEleveId
WHERE ter.intEvaluationElementId = 680
ORDER BY ter.intEvaluationElementId,te.strPrenom



Right now the query return nothing i want the query to return :

intEleveId strNom strPrenom intEvaluationElementId strNote
1 a b NULL NULL
2 aa dd NULL NULL


The reason i want to do that because the result will be in a table in asp.net ans strNote will be a textbox and the user will enter a score

I hope i exmplain my self right!

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-24 : 08:47:27
what happens when you change WHERE to AND?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

lucsky8
Posting Yak Master

105 Posts

Posted - 2010-02-24 : 08:53:00
quote:
Originally posted by madhivanan

what happens when you change WHERE to AND?

Madhivanan

Failing to plan is Planning to fail



Tks for the fast anwser i think it will work i will to change code a bit!
Tks for the help!
Go to Top of Page

DP978
Constraint Violating Yak Guru

269 Posts

Posted - 2010-02-24 : 08:57:51
How do you expect to get a null value for intEvaluationElementId when you explicitly state it needs to be 680?

intEleveId strNom strPrenom intEvaluationElementId strNote
1 a b NULL NULL
2 aa dd NULL NULL

EDIT: That May have been what Madiv was getting at...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-24 : 09:51:07
this is the reason

http://weblogs.sqlteam.com/jeffs/archive/2007/05/14/60205.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

DP978
Constraint Violating Yak Guru

269 Posts

Posted - 2010-02-24 : 09:56:42
Ah, thanks for the resource.

I got confused a bit, appreciate the response.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-24 : 10:00:37
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

lucsky8
Posting Yak Master

105 Posts

Posted - 2010-02-24 : 12:01:15
quote:
Originally posted by DP978

How do you expect to get a null value for intEvaluationElementId when you explicitly state it needs to be 680?

intEleveId strNom strPrenom intEvaluationElementId strNote
1 a b NULL NULL
2 aa dd NULL NULL

EDIT: That May have been what Madiv was getting at...




i put 680 but for real this select is in a stored procedure with a variable
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-24 : 12:03:56
quote:
Originally posted by lucsky8

quote:
Originally posted by DP978

How do you expect to get a null value for intEvaluationElementId when you explicitly state it needs to be 680?

intEleveId strNom strPrenom intEvaluationElementId strNote
1 a b NULL NULL
2 aa dd NULL NULL

EDIT: That May have been what Madiv was getting at...




i put 680 but for real this select is in a stored procedure with a variable


so what? that doesnt change the solution. just make it like


....
left JOIN tblM2EvaluationElementReponse as ter
ON ter.intElevesId = te.intEleveId
AND ter.intEvaluationElementId = @Yourvariable
...


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

lucsky8
Posting Yak Master

105 Posts

Posted - 2010-02-24 : 12:05:38
no
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-24 : 12:06:57
quote:
Originally posted by lucsky8

no


why??

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -