NOT IN在MYSql中不起作用.而Not Exists没有给出正确的结果


  1. 尝试使用not in((函数获取没有NULL或"字符串的记录,但不起作用。请提出任何建议。

    select * 
    from table 
    where colm1 = 'xyz' 
    and colm2 not in (NULL, '') 
    and id = 268594; 
    
  2. 在第二个场景中,我有表A和表B。表B可以有多个记录映射到一个表A记录。我想在表B上执行where子句。如果记录可用,则需要检查值是否为null或空。如何在不执行选择查询2次的情况下执行:

表A:

a_id 名称
1 "xyz">
select * 
from table 
where colm1 = 'xyz' 
and colm2 not in (NULL, '') 
and id = 268594; 

尝试使用IS NOT NULL<> '',例如:

select * 
from table 
where colm1 = 'xyz' 
and colm2 IS NOT NULL AND colm2<>''
and id = 268594; 

最新更新