Sql:将不同的行合并为一个

时间:2014-01-12 09:03:24

标签: sql join grouping

我不明白如何将多行的结果连接成一行。

更新:

解决方案应该可以轻松导出到主数据库服务器(MYSQL,postgresql,sql server,oracle ..)

上下文:

表1:

id_core int(11) UNSIGNED
definition varchar(32) utf8_general_ci  

表2:

id_core int(11) UNSIGNED
engine_type varchar(32) utf8_general_ci

以下是填写内容的示例:

表1:

1 blabblah
1 blahblah second / different component
1 blahblah third / different component
2 other stuffs
2 other stuffs on another component

表2:

1 engine type1
2 engine_type2

我目前得到什么:

select * from table1 
join table2
on table1.id_core = table2.id_core
where table1.id_core = 1

它导致:

1 - engine_type1 - blabblah
1 - engine_type1 - blahblah second / different component
1 - engine_type1 - blahblah third / different component

现在,我想减少检索的行数并获取:

1 - engine_tyoe1 - blabblah - blahblah second / different component - blahblah third / different component

然后我只得到一行而不是三行,这行已经包含了所有属性。

甚至可能吗?

由于

0 个答案:

没有答案