Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables student and TaskEffort. Many students must have worked on same task. For particular task the name of the students and effort should be considered.
The student table contains students info and TaskEffort table contains taskid, studentid, Effort

I need to display the taskid,first name,last name,effort. For those who worked on particular task.

Query I tried is
SQL
SELECT t.id, s.firstname,s.lastname, t.effort 
FROM taskeffort t 
LEFT OUTER JOIN student s ON t.id = 4 AND s.studentid = t.studentid

I need output only for task I'd 4 but I am getting for all task id .

Can someone help me out
Posted
Updated 16-Sep-15 3:05am
v2

1 solution

Hello,

Your join is causing issues.

SQL
SELECT t.id, s.firstname,s.lastname, t.effort
FROM taskeffort t
LEFT OUTER JOIN student s ON s.studentid = t.studentid
WHERE t.id = 4


If you want to get only task id = 4 records, it should be added in WHERE clause.

RelicV
 
Share this answer
 
v2

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