Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
My query as follows
 
  select fa.facname,f.bfid,b.class,b.examdate from bthfac f,batch b,faculty fa where month(b.examdate)= '11' and  year(b.examdate)= '2012'  and b.bthid=f.bthid and fa.facname = 'MADHAVAN'
 
when i execute the above query output as follows;
Facname         Bfid    class     examdate
MADHAVAN	542	RM	2012-11-01 
MADHAVAN	543	CTF	2012-11-02 
MADHAVAN	544	PSCRB	2012-11-02

facfeedback table as follows;
  Bfid   Rate
   542    1
   543	  2
   544    3
 
using the above query and facfeedback table i want to get thebelow output as follows;
 Facname         Bfid  class     examdate    rate
 MADHAVAN	542	RM	2012-11-01    1
 MADHAVAN	543	CTF	2012-11-02    2
 MADHAVAN	544	PSCRB	2012-11-02    3
 
for getting the above output how can i write the query.
 
please help me
 
Regards,
Narasiman P.
Posted 12-May-13 1:19am
Edited 14-May-13 12:32pm
Maciej Los152.3K
v2
Comments
Maciej Los at 14-May-13 17:32pm
   
Unclear! Please, be more specific and provide more details!

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The idea is this:
select 
 fa.facname
,f.bfid
,b.class
,b.examdate 
from 
bthfac f
inner join batch b on b.bthid = f.bthid
inner join facfeedback fb on fb.bfid=f.bfid
inner join faculty fa on fa.????=??.????
where 
 month(b.examdate)= '11' 
 and year(b.examdate)= '2012' 
 and fa.facname = 'MADHAVAN'
 
But be aware, that you select from faculty table without any join to the other tables. That look like a problem to me. But as I don't know the relations between the tables, I can not suggest you more. Of course, it might happen that you need something else than inner join, but that is more likely. When you select from a table without join or equivalent where condition you produce a Cartesian product - and it is unlikely that you need something like that in this situation.
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 14 May 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