Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 sqlite3 数据库,其中有一些像这样组织的表:date|type|zone|value。有很多条目,但只有几个区域。如何获得所有区域的列表,每个区域只有一次?
date|type|zone|value
每个表使用一个DISTINCT查询:
DISTINCT
for tablename in list_of_tablenames: cursor.execute('SELECT DISTINCT zone FROM {}'.format(tablename)) zones = [r[0] for r in cursor]