Click here to Skip to main content
Rate this: bad
good
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;
 
  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 30-Apr-13 2:23am
Edited 30-Apr-13 3:11am
(no name)152.3K
v2
Comments
CHill60 at 30-Apr-13 7:26am
   
What have you tried so far?
tumbledDown2earth at 30-Apr-13 7:56am
   
Start here: http://bit.ly/18jfUGY
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.
 
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)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 209
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2014
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