Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to use composite key in Sql query?

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2006-08-01 : 03:35:23
consider the following tables
1)Facultymaster
facultyid
2)Batch
batchid
lecturefacultyid
labfacultyid
3)batchlecture
facultyid
4)Feedback
batchid
facultyid
After matching above facultyid
for batch1 lecturefacultyid,lab_f_id=>3,2
for batch2 lecturefacultyid,lab_f_id=>2,4
in Feedback only
feedback for lab_f_id=>2 of batch1
therefore
i should get output as
-----------------------------
batch lectureid Feedback
------------------------------
batch1 3 Null
batch2 2 Null
But i get the output
batch1 3 Null
batch2 2 Some Feedback

How i can use composite key to identify the lab or lecture faculty in feedback table

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-01 : 06:04:59
Just include both columns in the join

on a.col1 = b.col1
and a.col2 = c.col2

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -