If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Another Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-09-03, 05:49
SAl SAl is offline
Registered User
 
Join Date: Sep 2003
Posts: 15
Another Query

Hello All,

This is another query I have to solve using SQL

Assume the following:

Transcript( stdid , crscode, Sem, Grade)
Teaching(Profid, crscode, Sem)
Professor( Id, ProfName, Dept)

The query is : find all student ids who had taken a course from each professor in the 'MAT' department

This is My attempt to solve the query :

SELECT DISTINCT T.stdid
FROM Transcript T, Professor P, Teaching Teach
WHERE Teach.profid = P.id AND P.Dept = 'MAT' AND
Teach.crscode = T.crscode

Am I so far right ?
Reply With Quote
  #2 (permalink)  
Old 10-10-03, 04:43
SAl SAl is offline
Registered User
 
Join Date: Sep 2003
Posts: 15
Hi

Here How I trace the answer :


1. All 'MUS' professors : MUSPROF = ð id (ó deptid= 'MUS' Professor)
2. JOIN with Teaching to obtain which course taught by whom
PROFCRS = (Teaching (JOIN profid=id) MUSPROF)

3. STDCRS = (Transcript (JOIN crscode = crscode) PROFCRS)
4. ð stdid, crscode (STDCRS).

where :
ð = project
ó = select
??
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On