求一条sql语句 ?? 求一条sql语句A,B,C三个表, A表字段Aname ,B表字段 Bname,C表字段Cname要求的结果是查询记录,A表Aname,B,表Bname的值,Aname,Bname在同一列出现。A中的Aname值不能等于C表中的Cname的值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select distinct [name] from (select [Aname] from A where [Aname] not in(select [Cname] from C)union all select [Bname] from B )t select Aname from Awhere exists(select 1 from B where Bname=a.Aname) and not exists(select 1 from C where Cname=a.Aname) select A.Aname from A,C where Aname<>Cnameunionselect Bname from B select Aname from Awhere exists(select 1 from B where Bname=a.Aname) and not exists(select 1 from C where Cname=a.Aname) select Aname from A where not exists(select 1 from C where Cname=a.Aname)union allselect Bname from B 这种效率比较高,只遍历了一次A表。select Aname from Awhere exists(select 1 from B where Bname=a.Aname) and not exists(select 1 from C where Cname=a.Aname) 求一存储过程 判断是否存在,如果不存在,就添加一条记录,如果存在,就返回另外两个字段ID与数量的值 关于EXCEL与SQL导入导出的问题 SQL的基础用法 如何在存储过程中将另一个存储过程返回的记录集(或输出参数)作为参数? 求一个验证表中存在循环关系的方法(解决问题马上结帖) 关于数视图中的数据行数据转换成列数据的问题 关于大小写的问题 视图的基本问题 帮忙看看sql语局 问一个变量赋值的问题。 急!求一触发器!在线结贴! 急啊~~~~~~~怎么可以查到Stored Procedure的创建时间?
select [Aname] from A where [Aname] not in(select [Cname] from C)
union all select [Bname] from B )t
where exists(select 1 from B where Bname=a.Aname)
and not exists(select 1 from C where Cname=a.Aname)
union
select Bname from B
select Aname from A
where exists(select 1 from B where Bname=a.Aname)
and not exists(select 1 from C where Cname=a.Aname)
select Aname from A where not exists(select 1 from C where Cname=a.Aname)
union all
select Bname from B
where exists(select 1 from B where Bname=a.Aname)
and not exists(select 1 from C where Cname=a.Aname)