Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Student table as follows;

studentid   studentname  marks  Qpname
1          Ram      70     MFA
1              Ram          80     TCF
1              Ram          80     AFF
1              Ram          80     PH2
2          Sam      70     MFA
2              Sam          80     TCF
2              Sam          80     AFF
2              Sam          80     PH2
3          Raja         70     MFA
3              Raja         80     TCF
3              Raja         80     AFF
3              Raja         80     PH2


Answer table as follows;
studentid  Qno
 1          2
 1          4
 1          10
 1          7
 2          3
 2          5
 2          6
 2          8
 3          7
 3          9
 3          10
 3          6


Course Table as follows;

CourseCode
 MFA
 TCF
 AFF
 PH2


Batch Table as follows;

Btchno     Batchdt       Attender
B1152      5/4/2010       RK
B1135      6/4/2013       MJ
B734       18/4/2013      SK
B802       24/4/2013      VG


From the above four table using i want the output as follows;


in run mode as follows;

Student id textbox1 Show (Button)

when i enter the student id and click the Show Button i want the output as follows from the database records'

Marks  Qpname Qno CourseCode  Btchno     Batchdt       Attender


for that how can i write the query using sqlserver
Posted
Updated 30-Apr-13 2:11am
v2
Comments
CHill60 30-Apr-13 7:26am    
What have you tried so far?
tumbledDown2earth 30-Apr-13 7:56am    
Start here: http://bit.ly/18jfUGY
Chetan Tembhre 30-Apr-13 8:11am    
Make batch table relation from any one table and try to do the inner join between all table
like select * from Student s inner join Answer a on s.studentid =a.studentid where s.studentid=your text box value
vijay__p 30-Apr-13 8:25am    
There is no relation to/from Batch table.
Add column BatchNo to Student table and then use below query.

SELECT
S.Marks, S.QPName, A.Qno, C.CourseCode, B.BatchDt, B.Attender
FROM Student S INNER JOIN Answer A
ON S.StudentID = A.StudentID
INNER JOIN Course C
ON S.QPName = c.CourseCode
INNER JOIN Batch B
ON B.BatchNo = S.BatchNo

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