当前位置: 代码迷 >> Sql Server >> 2列数据对比要如何写代码
  详细解决方案

2列数据对比要如何写代码

热度:31   发布时间:2016-04-27 15:54:05.0
2列数据对比要怎么写代码啊
一个表里有A,B   2列格式一样的数据,把B列数据依次在A列中查找,如果能找到的就不要,不能找到的按顺序写入c列或者新表的一列

这个代码怎么写啊

------解决方案--------------------
select B from test as t--加一个别名
where not exists(select * from test where A=t.B)--嵌套t.b 为t表的b没有对应所以有无效提示
------解决方案--------------------
楼上漏加了表别名
select B from test t where not exists(select * from test where A=t.B)
  相关解决方案