Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PostgreSQL中如何组合不在和喜欢?_Postgresql_Sql Like_Notin - Fatal编程技术网

在PostgreSQL中如何组合不在和喜欢?

在PostgreSQL中如何组合不在和喜欢?,postgresql,sql-like,notin,Postgresql,Sql Like,Notin,如何将不在中与类似的组合 假设我们有一个表,其中包含一列名称(如“blue cheese”、“gouda cheese”等),我想选择所有不包含“cheese”、“milk”、“meat”的名称 据我所知,要查找不在字符串数组中的内容,请使用而不是并传递字符串 SELECT names FROM some_table NOT IN('cheese','milk','meat'); 但是我怎么通过呢 LIKE '%cheese%' 对它来说?构造就像任何(数组[…])一样,似乎满足了您的需要

如何将
不在
中与
类似的组合

假设我们有一个表,其中包含一列名称(如“blue cheese”、“gouda cheese”等),我想选择所有不包含“cheese”、“milk”、“meat”的名称

据我所知,要查找不在字符串数组中的内容,请使用
而不是
并传递字符串

SELECT names FROM some_table NOT IN('cheese','milk','meat');
但是我怎么通过呢

LIKE '%cheese%'

对它来说?

构造
就像任何(数组[…])
一样,似乎满足了您的需要

craig=> SELECT a FROM (
           VALUES ('cheesy'), ('imilk'), ('donut'), ('pie'), ('avocado'), ('meaty')
        ) x(a) 
        WHERE NOT a LIKE ANY (ARRAY['%cheese%','%milk%','%meat%']);

    a    
---------
 cheesy
 donut
 pie
 avocado
(4 rows)
如果希望像这样使用
之类的
,则需要通配符。如果您真的想要平等,可以使用:

NOT = ANY (...)

@boo\u boo\u熊:或者
哪里有!~ALL(…)
/
其中,如果不涉及
NULL
值,则为ALL(…)