连接查询的语句
我有2个表
查询表一的 reportname,path内容
要求,返回 reportname 不包含在 表二 reportname的列中,表二的列为username=xxx,
我无论用 <> ,not in都是取不到正确的结果
而,IN , = 可以取到相反要求的正确结果。。怎么搞啊
SELECT dbo.ReportList.*
FROM dbo.ReportList INNER JOIN
dbo.UserReport ON dbo.ReportList.ReportName <> dbo.UserReport.ReportName
------解决方案--------------------SELECT dbo.ReportList.*
FROM dbo.ReportList a,
dbo.UserReport b where a.ReportName <> b.ReportName
------解决方案--------------------select reportname,path from ReportList where reportname not in (select reportname from UserReport )
------解决方案--------------------SELECT dbo.ReportList.*
FROM dbo.ReportList a,
dbo.UserReport b where isnull(a.ReportName, ' ') <> isnull(b.ReportName, ' ')
------解决方案--------------------select * from ReportList a where not exists(select * from UserReport where ReportName=a.ReportName)
------解决方案----------------------try
SELECT dbo.ReportList.*
FROM dbo.ReportList as A
where exists(select 1 from UserReport where ReportName <> A.ReportName)
------解决方案--------------------SELECT dbo.ReportList.*
FROM dbo.ReportList as A
where A.ReportName NOT IN (select ReportName from UserReport)