【发布时间】:2015-09-08 04:49:41
【问题描述】:
我有以下表格和一些数据:
Collector:
dcid name hostid userid
123 test host1 234
567 hello host2 345
CollectorConfiguration:
ID propertyname propertyvalue collector_id(foreign key)
id1 c_source local 123
id2 c_createdby admin 123
id3 c_pattern JBoss 123
id4 c_source remote 567
id4 c_createdby admin 567
id4 c_pattern Apache 567
现在我需要从 Collector 表中获取所有记录,并对 CollectorConfiguration 表中的列值“c_pattern”进行排序。
我尝试使用内部联接编写查询,但无法获得所需的结果。请帮忙。
注意:返回的结果只包含 Collector 表的列,即它应该表现得像 select * from Collector 但在 c_pattern 属性值上带有 sortinn。
Desired output(with ascending order on c_pattern):
567 hello host2 345
123 test host1 234
【问题讨论】:
-
你应该提供你想要的输出。也向我们展示你尝试了什么。
-
在
propety name "c_pattern"上排序是什么意思??您对不在该列值中的列进行排序,除非您的意思是按该值过滤。 -
@JuanCarlosOropeza 我已经相应地编辑了问题。如果您需要任何其他信息,请告诉我。
-
是的,您要求订购,但我没有看到任何订单。看起来您要求只选择一个
collector_id,看不到您使用propertyname -
如果您看到 ColectorConfiguration 表,对于 colelctor(123),c_pattern 值为 JBoss,对于 colelctor(567),c_pattern 值为 Apache。所以排序应该做c_pattern值。