开发者

Several translation joins in sql

A primary table holds info about things with int id's.

Translations for these id's are in second table. Id of second table refers to primary table id's, and holds textual description of these. I need a hint how to write a sql select clause to get all the fields from primary table so that all its id values a开发者_如何学Gore shown as translation texts?


Assuming Table1 have id1, id2, id3 and table2 the translations, I will do something like that (not tested):

Select T1.ID1, T1.ID2, T1.ID3, T21.Translation as Name1, T22.Translation  as Name2, T23.Translation  as Name3,
from Table1 T1 left join Table2 T21 on T1.Id1 = T21.Table1_ID
   left join Table2 T22 on T1.Id2 = T22.Table1_ID
   left join Table2 T23 on T1.Id3 = T23.Table1_ID


something like this:

select table1.*, table2.description from table1, table2 
where table1.id = table2.id;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜