我正在尝试检索每个表名的列列表
假设我有下表
('tableA', 'columnA', 1)
('tableA', 'columnB', 2)
('tableB', 'columnA', 1)
('tableB', 'columnB', 2)
('tableC', 'columnA', 1)
('tableD', 'columnA', 1)
如何返回按相同表名分组的列表? 所以它返回以下内容
('tableA', 'columnA', 'columnB')
('tableB', 'columnA', 'columnB')
('tableC', 'columnA')
('tableD', 'columnA')
你可以用^{} 来做这个。请注意,这要求首先按表名对列表进行排序,但在您的情况下似乎是这样。否则,请先排序
或者使用字典(或^{} ),将表名映射到列:
相关问题 更多 >
编程相关推荐