过去几天我一直试图想出以下几点。
table1:同义词
Id Synonym code
------------------------------
1 Car Tyre 001
2 Bike Tyre 002
3 Cycle Tyre 003
4 Hammer Tube 001
现在我的输入='来自Hammer Tube AUDI 2000的汽车轮胎'
输出=列表代码' 001'两次,因为输入文本包含' CAR TIRE'和' Hammer Tube'
当我尝试以下查询时,它只显示一次,但我需要两次
Select * from synonym where 'WITH CAR TYRE FROM Hammer Tube AUDI 2000' ~ Synonym;
答案 0 :(得分:1)
将position()
与lower()
结合使用:
with synonym(id, synonym, code) as (
values
(1, 'Car Tyre', '001'),
(2, 'Bike Tyre', '002'),
(3, 'Cycle Tyre', '003'),
(4, 'Hammer Tube', '001')
)
select *
from synonym
where position(lower(synonym) in lower('WITH CAR TYRE FROM Hammer Tube AUDI 2000')) > 0
id | synonym | code
----+-------------+------
1 | Car Tyre | 001
4 | Hammer Tube | 001
(2 rows)