I tried something like this but it doesnt work. Thank you.. "SELECT table_1.id FROM table_1 CASE WHEN (table_1.pid <> 0) THEN LEFT JOIN table_2 ON table_1.pid = table_2.id WHEN (table_1.nid <> 0) THEN LEFT JOIN table_3 ON table_1.nid = table_3.id END"
2009/2/24 Ali Deniz EREN <ali.deniz.e...@gmail.com> > table_1 > id pid nid > ----------------------- > 1 6 0 > 2 0 5 > > table_2 (referer -> pid) > id title body > ----------------------- > 1 title1 body_text1 > 2 title2 body_text2 > 3 title3 body_text3 > 4 title4 body_text4 > 5 title5 body_text5 > 6 title6 body_text6 > 7 title7 body_text7 > > table_3 (referer -> nid) > id ntitle nbody > -------------------------- > 1 ntitle1 nbody_text1 > 2 ntitle2 nbody_text2 > 3 ntitle3 nbody_text3 > 4 ntitle4 nbody_text4 > 5 ntitle5 nbody_text5 > 6 ntitle6 nbody_text6 > 7 ntitle7 nbody_text7 > > I want to get values table_2 and table_3 according to table_1. As a result, > it must be as below. > > id title body > ------------------------ > 6 title6 body_text6 > 5 ntitle5 nbody_text5 > > > What would be the query? > > Thanks for your help. > > -- > Ali Deniz EREN > ali.deniz.e...@gmail.com > -- Ali Deniz EREN ali.deniz.e...@gmail.com