在 MYSQL 中使用 NOT LIKE 并获取子查询错误

using of NOT LIKE in MYSQL & getting error of SubQuery

我使用下面的 mysql 查询来获取数据:

select * 
from tableName 
where tableName.field_type='22' 
  and tableName.field_id NOT LIKE(select aField_id 
  from TableName 02 where status !='Active')

我遇到错误

1242 - 子查询 returns 多于 1 行

你能告诉我这个查询有什么问题吗

select * from tableName
         where tableName.field_type='22' 
        and 
        tableName.field_id 
        NOT IN(select aField_id from TableName  where status !='Active')

使用 not in 代替 not likeNot in 用于将列与一组值进行比较。 not like 用于比较具有单个值或模式的列。您的子查询返回多行。 not like 无法处理。

喜欢只处理一个输入。所以你应该用 IN 代替 LIKE。