-1
我有一个表location
,它包含id
列中的值A1, A2, A3...
等。我还有一个表location_color
这样的:SQL查询的逗号分隔结果
A1 blue
A1 red
A1 green
A2 yellow
A2 red
A3 blue
A3 red
.
.
现在我想查询这样的结果会是这样
blue,red,green
yellow,red
Blue, red
我的查询是
select location_color.color
from location_color
where location.id = location_color.location_id
,但它不工作。
在MySQL中,你可以使用'GROUP BY'和'GROUP_CONCAT()' –
哪个RDBMS(供应商和版本)?标记* sql *是不够的... – Shnugo
你没有包含'location'表。但是,当你没有使用'location'表中的任何东西时,为什么你想拥有'where'子句?只要把那个'出去吧。 – trincot