1.这两句有啥区别,我是在postgresql里,发现一模一样....
select * from articles where link like '%'||'a'||'%';
select * from articles where link like '%a%';
2.另外 如果我有list = ['a','b','c']
select * from articles where link like '%'||'a'||'%' and link like '%'||'b'||'%' and link like '%'||'c'||'%';
如何简化上面这一句呢?python
or in SQL
.
3.我看了这篇文章,了解了PATINDEX,但是在postgresql里并不能执行,为啥提示不存在patindex
。
有没有人可以讲解一下patindex
是啥。
SELECT * from articles where patindex('%a%',site) > 0;
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Query failed
学生,新手。
十分感谢!
如果用字符匹配功能,要求字符串同时含有a,b,c,除了像你那样用 and 连接 like 也想不出什么其他好办法。如果把字符串打散成一个array,转而判断集合的包含关系,可以这样: