Click here to Skip to main content
13,042,166 members (92,258 online)
Rate this:
Please Sign up or sign in to vote.
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;


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 30-Apr-13 1:23am
Updated 30-Apr-13 2:11am
Maciej Los255.3K
CHill60 30-Apr-13 7:26am
What have you tried so far?
tumbledDown2earth 30-Apr-13 7:56am
Start here:
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
patel_vijay 30-Apr-13 8:25am
There is no relation to/from Batch table.
Add column BatchNo to Student table and then use below query.

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100