本人写了以下语句
select distinct jh from ytk_tc
except
select distinct jh from ytk_yxtx
求差集通过不了,报错说Msg 156, Level 15, State 1, Line 3
在关键字 'except' 附近有语法错误。select distinct jh from ytk_tc和
select distinct jh from ytk_yxtx 单独执行都没问题?
select distinct jh from ytk_tc
except
select distinct jh from ytk_yxtx
求差集通过不了,报错说Msg 156, Level 15, State 1, Line 3
在关键字 'except' 附近有语法错误。select distinct jh from ytk_tc和
select distinct jh from ytk_yxtx 单独执行都没问题?
解决方案 »
- 请教一个关于数据库同步的问题!诚心,急!
- 记录集数据不能更新
- 我配置出版服务器,出现“susu"的sql server代理当前在使用系统帐户,它会导致服务器之间的复制失败,请高手指点,在线等~~
- 急!求解sql查询问题
- 根据行政区划代码 如何生成所在“省、市、县”的查询
- SQL Server 2个表整合在一起 求大侠帮忙
- 扩展存储过程中如何判断网络不通的异常_______谢谢谢谢谢谢谢谢
- 小弟初学数据库,有关存储过程的问题
- 表名做为存储过程的参数老报错,如何解决
- BCB版各位老大:请问InterBase和MSSQL Server,我该选那个?(详情入内)《CKER》
- sqlServer2005新增一个数据库实例,应该如果操作
- case when 可以嵌套吗?
except不能这样用吧
这个函数不能在sql语句中使用...
union
select distinct jh from ytk_yxtx
union all --不合并连接的重复项用
select distinct jh from ytk_yxtx
where jh not in (
select distinct jh from ytk_yxtx
)or:select distinct jh from ytk_tc
where not exists (
select 1 from ytk_yxtx where jh=ytk_tc.jh
)
except 不是sql server数据库的关键字是sql Analysis Services 的关键字
查找两个集合之间不同的项,可以选择保留重复项。语法
Except(«Set1», «Set2»[, ALL])注释
在查找不同的项之前先消除两个集合中的重复项。可选的 ALL 标志保留重复项。清除 «Set1» 中的匹配重复项并保留非匹配重复项。示例Except({Canada, [British Columbia], Mexico, [British Columbia], USA, Washington}, {Canada, Mexico, California})返回{[British Columbia], USA, Washington}示例Except({Canada, [British Columbia], Mexico, [British Columbia], USA, Washington}, {Canada, Mexico, California}, ALL)返回{[British Columbia], [British Columbia], USA, Washington}.
except
select id from 表A where 列A=2
select distinct jh from ytk_tc where jh not in (select distinct jh from ytk_yxtx)
where jh not in (
select distinct jh from ytk_yxtx
)
union all
select distinct jh from ytk_yxtx
where jh not in (
select distinct jh from ytk_tc
)
-----------------------------------------------------
select distinct jh from ytk_tc
where jh not in (
select distinct jh from ytk_yxtx
)
只表示ytk_tc有,ytk_yxtx没有的记录
不能表示ytk_tc没有,ytk_yxtx有的记录