【发布时间】:2017-01-16 09:39:39
【问题描述】:
我将使用 for/each 循环,使用正则表达式在另一个表 (table2) 中记录的文本信息中搜索不同的名称 (table1)。
SELECT id FROM "table1"
where tags ~* 'south\s?\*?africa'
or description ~* 'south\s?\*?south'
order by id asc;
但我不知道如何将其放入 for each 循环中!
table1:
t1ID | NAME
1 | Shiraz
2 | south africa
3 | Limmatplatz
table2:
t2ID |TAGS | DESCRIPTIONS
101 |shiraz;Zurich;river | It is too hot in Shiraz and Limmatplatz
201 |southafrica;limmatplatz| we went for swimming
我在table1 中有一个姓名列表。另一个表有一些可能包含这些名称的文本信息。
我想取回 table2 的 ID,其中包含 table1 中的项目以及项目的 ID。
例如:
t2id | t1id
101 |1
101 |3
201 |2
201 |3
我的表有 60,000 和 550.000 行。 我需要使用一种时间明智的高效方式!
【问题讨论】:
标签: regex performance postgresql for-loop database-design