我有一些列的資料庫,我有 N 個引數。我需要獲取列在任何列中都有所有 N 引數的行。
例子:
id title place author
1 'Book Example1' 'shelves' 'John Johnson'
2 'Book Example2' 'library' 'John Johnson'
像['shelves', 'John Johnson']這樣輸出的引數將是具有 1 個 id 的行。
誰能幫我這個?不知道如何通過 SQL 做到這一點
uj5u.com熱心網友回復:
全文搜索的簡單替代方案。將每一行塑造成單個文本字串,并將其與引數陣列('{shelves,John Johnson}'::text[]在下圖中)作為正則運算式進行匹配。
select * from the_table t
where t::text ~* all('{shelves,John Johnson}'::text[]);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/399491.html
標籤:sql PostgreSQL的
