Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a problem to joinig Tables of my database in select statement.
I created 3 table in my database . here is my table :
Table 'Persons' with column{ID , Name,Type}
(//ID is primary key , Type is nvarchar with value of 'teacher' or 'student')
Table 'Teachers' with column{TID,Course} //TID is foreign key for Persons.ID
Table 'Student' with column{SID,Grade} //SID is foreign key for Persons.ID


Now I want to select all column of Persons with extra new column wich it's content will be determined by column 'Type'. if Type is teacher it retrieve value of column 'Cource' of Teacher table and if Type is Student it retrieve value of column Grade of Student table . How my select statement.I should be ? hope you understand what I mean .
Thanks for your help.
Posted
Updated 12-Sep-11 2:58am
v2
Comments
#realJSOP 12-Sep-11 8:59am    
What have you tried?

1 solution

Did you realize that you have no way to associate a student with a course? Sure, he has a grade, but what course is it for?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900