In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "what are the Putting multiple LIKE patterns into an array features in PostgreSQL". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the Putting multiple LIKE patterns into an array features in PostgreSQL"?
LIKE is used for fuzzy queries, such as select from tablename where column like'% value%';. If multiple fuzzy matches are required, multiple like clauses are required, such as select from tablename where column like'% value1%' or column like'% value2%' or column like'% value3%' or select * from tablename where column like'% value1%' and column like'% value2%' and column like'% value3%'. PG provides ANY/ALL in conjunction with ARRAY to simplify SQL:
Select from tablename where column like'% value1%' or column like'% value2%' or column like'% value3%'
->
Select from tablename where column like ANY (ARRAY ['% value1%','%value2%','%value3%'])
Select from tablename where column like'% value1%' and column like'% value2%' and column like'% value3%'
->
Select from tablename where column like ALL (ARRAY ['% value1%','%value2%','%value3%'])
Test script
[local]: 5432 pg12@testdb=# create table t_like (id int,c1 varchar (20)); CREATE TABLETime: 160.410 ms [local]: 5432 pg12@testdb=# [local]: 5432 pg12@testdb=# insert into t_like (id,c1) values; INSERT 0 1Time: 14.815 ms [local]: 5432 pg12@testdb=# insert into t_like (id,c1) values INSERT 0 1Time: 1.423 ms [local]: 5432 pg12@testdb=# insert into t_like (id,c1) values; INSERT 0 1Time: 1.486 ms [local]: 5432 pg12@testdb=# select * from t_like where C1 like ANY (ARRAY ['% test%','% Test%']) Id | C1-+-1 | asdfafetestsdfasdf 2 | asdfafe Test sdfasdf 3 | astestfe Test sdfasdf (3 rows) Time: 48.319 ms [local]: 5432 pg12@testdb=# select * from t_like where C1 like ALL (ARRAY ['% test%','% Test%']) Id | C1-+-3 | astestfe test sdfasdf (1 row) Time: 2.463 ms [local]: 5432 pg12@testdb=# so far, I believe you have a better understanding of "what are the Putting multiple LIKE patterns into an array features in PostgreSQL". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.