0

Sir, having a problem. I have two tables i.e directives and para_comments_sect. there is no direct connection with each other . what i want is to get the data field from directives and para_comments_sect of para_id=15 ( its a foreign key from para table).
any suggestions and guidance for it ?

   1.**directives** fields are ; id(pk), comments, para_id(fk) 
    2.**para_comments_sect** fields are; id(pk), comments, para_id(fk)
    3.**para** , its fields are ; id,para_no,para_title

actually i am in final stages of a project , other idea was to insert a new foreign key id from directives into para_comments_sect which now i cannot as data has been inserted into fields
any suggestions and guidance for it ?

2
Contributors
1
Reply
8
Views
4 Years
Discussion Span
Last Post by adam_k
0

You should join all 3 tables and only select from the 2 you need to:

select directives.comments, para_comments_sect.comments 
from directives inner join para on directives.para_id = para.id 
inner join para_comments_sect.para_id = para.id 
where para.id = 15 -- replace the where clause with whatever you need to

select directives.comments, para_comments_sect.comments
from directives inner join para on directives.para_id = para.id
inner join para_comments_sect.para_id = para.id
where para.id = 15 -- replace the where clause with whatever you need to

Edited by adam_k

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.