已编辑:在SQL中,我将带有文本列的表连接到单独的表(后者在下面的示例中未描述)。我想显示来自每一行的文本,这些文本串联成一行。我想使用一个单独的列(“行”)来确定文本的连接顺序。
>>> rows[0].xpath('.//*[@id="horizontal-list"]')
[]
>>> rows[0].xpath('.')
[<Selector xpath='.' data='<ul id="horizontal-list">\n\t\t\n<li><a href'>]
>>> rows[0].xpath('.//li[1]/a/@href')
[<Selector xpath='.//li[1]/a/@href' data='http://www.lawncaredirectory.com/statedi'>]
>>> rows[0].xpath('.//li[1]/a/@href').get()
'http://www.lawncaredirectory.com/statedirectory.php?state=Alabama'
单列/行输出:
li[1]
答案 0 :(得分:1)
在postgresql中尝试一下:
select string_agg(Str,' ' order by Line ) as Sentence FROM Table1
group by Col;
输出:
sentence
This is a sentence
答案 1 :(得分:1)
在MySql中尝试:
select group_concat(Str order by Line separator ' ' ) as Sentence FROM Table1
group by Col;
结果:
sentence
This is a sentence