Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have three different tables,

course no Course name - table1


paper id paper name - table2


Course no Paper id - table3

how do i get the corresponding paper names using the course id?
Posted
Comments
ssd_coolguy 24-Aug-12 2:02am    
what you have tried?
codingisok101 24-Aug-12 2:04am    
Select CourseName,PaperName from Table1,Table2 where table3.courseno=table1.courseno;
Kuthuparakkal 24-Aug-12 2:35am    
Go to W3school and learn SQL joints:
http://www.w3schools.com/sql/sql_join.asp

there is some standard we expect from questions.

try below code...
if you want only course no ans paper name..

SQL
select table3.course_no,table2.paper_name
 from table2 inner join table3
on table2.Paper_id=table3.Paper_id
where on table3.course_no= '2'
 
Share this answer
 
v2
Comments
codingisok101 24-Aug-12 2:14am    
so is table1 not required?
ssd_coolguy 24-Aug-12 2:19am    
you asked for course_no and paper_name
if you want course name then it requires table1..
SQL
SELECT tb2.paperName
FROM 
table2 as tb2
INNER JOIN
table3 as tb3
WHERE tb2.paperID = tb3.PaperID
AND tb3.CourseNo = --Any value

You are not following naming conventions properly.
Please try to implement that and name your tables and fields properly.
 
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