测试数据:
create temp table l (id integer,name text);
create temp table t (id integer);
create temp table t_i18n(id integer,l_id integer,t_id integer,name text);
insert into l(id, name) values
(1, 'lang_1'),
(2, 'lang_2');
insert into t(id) values(1);
insert into t_i18n(id, l_id, t_id, name) values
(1, 1, 1, 'Text in the language one'),
(2, 2, 1, 'Text in the language two');
执行此查询后:
select *
from t
inner join t_i18n i18n
on i18n.t_id = t.id;
我有这个结果:
id | id | l_id | t_id | name
----+----+------+------+--------------------------
1 | 1 | 1 | 1 | Text in the language one
1 | 2 | 2 | 1 | Text in the language two
是否可以修改上面的查询以获得下面的结果?
/*Expected result*/
id | name_lang_1 | name_lang_2
----+--------------------------+--------------------------
1 | Text in the language one | Text in the language two