关于sql数据库的不等于如何正确使用

select distinct 表1 from 数据库1 where (select count(*) from 数据库1 e where e.表2=数据库1.表2 and e.表3<>数据库1.表3 and e.表4=HP.表4 ) >1
无结果(<>和!=都试了,不是我想象的3个结果)

select distinct 表1 from 数据库1 where (select count(*) from 数据库1 e where e.表2=数据库1.表2 and e.表3=数据库1.表3 and e.表4=HP.表4 ) >1
2个结果

去掉表3判定
select distinct 表1 from 数据库1 where (select count(*) from 数据库1 e where e.表2=数据库1.表2 and e.表4=HP.表4 ) >1
是5个结果
已经找出来了,不等于的确有问题,不能这样写,逻辑错误
你的逻辑有问题,可以把数据贴上来看下,要不不明白你到底是啥意思.
这种select 语句第一次见
关于sql数据库的不等于如何正确使用
← 上一篇: 下一篇: →