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 ?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.