Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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 2:23am
Edited 30-Apr-13 3:11am
(no name)167.6K
CHill60 at 30-Apr-13 7:26am
What have you tried so far?
tumbledDown2earth at 30-Apr-13 7:56am
Start here:
Chetan Tembhre at 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 at 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
0 OriginalGriff 959
1 Sergey Alexandrovich Kryukov 886
2 Kornfeld Eliyahu Peter 575
3 Peter Leow 558
4 ProgramFOX 345

Advertise | Privacy | Mobile
Web03 | 2.8.150302.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2015
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