we have three tables.
tblA
id(PK) doc_id(fk) mr_id(fk) date
-------- ---------- -------- ---------
1 23 22 2012-05-23
2 24 22 2012-05-23
3 25 21 2012-05-24
4 26 22 2012-05-24
tblB
doc_id(PK) d_name d_segId(FK) mr_id(FK)
------------ ------------- ---------- ----------
1 manish 1 12
23 rahul 2 22
24 paul 1 22
25 jacky 1 21
26 amit 2 22
tblC
seg_id(PK) seg_name seg_color
-------- ---------- --------
1 A_corei red
2 Bcorec green
what i want is all the record from tblA where mr_id=22 and date=’2012-05-23′ and order by seg_name in tblC
doc_id is referenced to tblB and
on the basis of doc_id, Seg_id is referenced to tblC how to use join in this situation.
It should look like
id doc_id d_name seg_color
-------- --------- --------- ----------
1 23 rahul green
2 24 paul red
1 Answer