select
a.spid as 总店商品ID,
... ,
b.spid as 本店商品ID,
... ,
case
when a.spbh != b.spbh then '编号不同'
when a.spmch != b.spmch then '名称不同'
when a.shpgg != b.shpgg then '规格不同'
end as 商品差异
from
zdspkfk a
inner join
spkfk b
on
a.glid=b.spid
where
a.spbh != b.spbh or a.spmch != b.spmch or a.shpgg != b.shpgg
a.spid as 总店商品ID,
... ,
b.spid as 本店商品ID,
... ,
case
when a.spbh != b.spbh then '编号不同'
when a.spmch != b.spmch then '名称不同'
when a.shpgg != b.shpgg then '规格不同'
end as 商品差异
from
zdspkfk a
inner join
spkfk b
on
a.glid=b.spid
where
a.spbh != b.spbh or a.spmch != b.spmch or a.shpgg != b.shpgg
解决方案 »
- 请问一个string转换为datetime的问题?
- sql server 2005 express中有作业么?在哪里进?
- 表锁问题,高手请进
- 请问一个超级超级郁闷的问题关于access的带参数视图转换为sqlserver存储过程
- 有个合并的问题;
- 請問怎樣在本機建立cobe編輯器?
- DELPHI+SQL SERVER2000如何在没SQL SERVER2000的机子上用?
- 大家帮帮忙,这个语句怎么写
- 请问,哪位大神可以帮我修改下我写的网站吗?jsp+sqlserver2005
- 求助删除多余数据
- 谁有直接能体现索引能提高查询速度的例子?
- 基本问题:SQLserver2000如何在有递增标识的字段的表中插入新记录?
a.spid as 分店商品ID,a.spbh as 分店商品编号,a.spmch as 分店商品名称,a.shpgg as 分店商品规格,
b.spid as 总店商品ID,b.spbh as 总店商品编号,b.spmch as 总店商品名称,b.shpgg as 总店商品规格,
case
when (a.spbh != b.spbh) and (a.spmch=b.spmch) and (a.shpgg=b.shpgg) then '编号不同'
when (a.spmch != b.spmch) and (a.spbh=b.spbh) and (a.shpgg=b.shpgg) then '名称不同'
when (a.shpgg != b.shpgg) and (a.spbh=b.spbh) and (a.spmch=b.spmch) then '规格不同'
when (a.spbh !=b.spbh) and (a.spmch !=b.spmch) and (a.shpgg=b.shpgg) then '编号与名称不同'
when (a.spbh !=b.spbh) and (a.shpgg !=b.shpgg) and (a.spmch=b.spmch) then '编号与规格不同'
when (a.spbh !=b.spbh) and (a.spmch !=b.spmch) and (a.shpgg !=b.shpgg) then '都不同'
when (a.spbh = b.spbh) and (a.spmch !=b.spmch) and (a.shpgg !=b.shpgg) then '名称和规格不同'
end as 商品差异
from
fdspkfk a
inner join
spkfk b
on
a.glid=b.spid
where
(a.spbh != b.spbh or a.spmch != b.spmch or a.shpgg != b.shpgg) and a.fdbs='hyjc'这么写为什么不行呢
where not exists
(select 1 from spkfk b where
a.glid=b.spid and (a.商品编号<>b.商品编号 or
a.商品名称<>b.商品名称 or a.商品规格<>b.商品规格))
union allselect * from spkfk a
where not exists
(select 1 from zdspkfk b where
a.glid=b.spid and (a.商品编号<>b.商品编号 or
a.商品名称<>b.商品名称 or a.商品规格<>b.商品规格))
select a.商品编号, a.商品名称, a.商品规格 from zdspkfk a
where not exists
(select 1 from spkfk b where
a.glid=b.spid and (a.商品编号<>b.商品编号 or
a.商品名称<>b.商品名称 or a.商品规格<>b.商品规格))
union allselect a.商品编号, a.商品名称, a.商品规格 from spkfk a
where not exists
(select 1 from zdspkfk b where
b.glid=a.spid and (a.商品编号<>b.商品编号 or
a.商品名称<>b.商品名称 or a.商品规格<>b.商品规格))