Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的查询,但它没有选择任何东西,但它应该。所以查询
SELECT * FROM _custom_access_call WHERE CONCAT(type, name) NOT IN ('string1', 'string2', 'string3')
我用 null 和 '1sfgsg' 值手动添加到表条目,但它没有被选中。为什么?我需要选择所有 concat 值不在数组中的条目。帮助处理它。
如果其中一个值是NULL,CONCAT()则将返回NULL。而且NULL NOT IN (...)总是NULL。也是NULL IN (...)一直NULL。如果你想使用NULL你应该明确地处理它。在这种特定情况下,CONCAT_WS()有帮助,因为它永远不会返回NULL。
NULL
CONCAT()
NULL NOT IN (...)
NULL IN (...)
CONCAT_WS()
SELECT * FROM _custom_access_call WHERE CONCAT_WS('', type, name) NOT IN ('string1', 'string2', 'string3');
另请注意,此查询不能使用任何索引。