Querry three different tables

  • Thread starter Thread starter Mario
  • Start date Start date
M

Mario

Lets say I have the following three tables:

Table Name: "Students"

StudentID StudentName
1 Katie
2 David
3 Matt
4 Angie


Table Name: HonorStudents

HonorStudentID StudentName
1 David
2 Angie



Table Name: GiftedStudents

GiftedStudentID StudentName
1 David
2 Matt


Can any one please help me prepare a querry that reports
all the records in "Students" table in the following way:

StudentName IsHonorStudent IsGiftedStudent
Katie No No
David Yes Yes
Matt No Yes
Angie Yes No


Thanks, Please help
 
Try this ...

SELECT *, False As IsHonor , False As IsGifted FROM Students
UNION SELECT *, True As IsHonor , False As IsGifted FROM HonorStudents
UNION SELECT *, False As IsHonor , True As IsGifted FROM StudentName
ORDER BY StudentName ASC
 
Ooops, I named the last table incorrectly
SELECT *, False As IsHonor , False As IsGifted FROM Students
UNION SELECT *, True As IsHonor , False As IsGifted FROM HonorStudents
UNION SELECT *, False As IsHonor , True As IsGifted FROM GiftedStudents
ORDER BY StudentName ASC

--

Danny J. Lesandrini
(e-mail address removed)
http://amazecreations.com/datafast


"
 
Back
Top