我的客戶想要的可能性,一組數據的匹配對正則表達式的數組的數組匹配,這意味着:的Postgres對正則表達式
table:
name | officeId (foreignkey)
--------
bob | 1
alice | 1
alicia | 2
walter | 2
,他想沿着這些線路做一些事情:
讓我辦公室的所有記錄(officeId)凡有與
ANY name ~ ANY[.*ob, ali.*]
meaning
ANY of[alicia, walter] ~ ANY of [.*ob, ali.*] results in true
成員,我不能獨自黯然看着辦吧:/。
編輯
真正的問題是缺少形式的原始描述:
我不能使用select disctinct officeId .. where name ~ ANY[.*ob, ali.*]
,因爲:
本申請,在postgres的XML列存儲的數據,這意味着我確實有(在評估xpath('/data/clients/name/text()'))::text[]
後):
table:
name | officeId (foreignkey)
-----------------------------------------
[bob, alice] | 1
[anthony, walter] | 2
[alicia, walter] | 3
有問題。 「你不這樣做,那太可怕了,你爲什麼要這樣做,將它存儲爲存儲在關係數據庫中,使用基於文檔的存儲的非sql數據庫,使用json」沒有選擇。
我被這個datamodel卡住了。
你能不能用'名〜或名稱〜 '阿里*。''? –
'... where name〜any(array ['。* ob','ali。*'])' – Abelisto
如果我能做到這一點很簡單,我會意識到我寫的並不表達核心的問題,這是之前選擇的基礎瘋狂數據模型進入項目。 - 我編輯了這個問題 – billdoor