当前位置: 代码迷 >> Oracle开发 >> 急Oracle SQL求指导
  详细解决方案

急Oracle SQL求指导

热度:46   发布时间:2016-04-24 07:19:47.0
急!Oracle SQL求指点
表 A
nameid
ABC
AB1
AB2
AB3
BA1
BA2
BA3
AC2

表 B
nameid
AB*
AC*
BA1

现在要的结果是表A中不满足表B,*可以代表任意字符

结果应该是
nameid
BA2
BA3

不过B表不是固定的,有时候没有任何数据,有时候有。
求大神指点一下,谢谢。

------解决方案--------------------
SQL code
select nameid from A where not exists (select 1 from B where a.nameid like replace(B.nameid,'*','%'));
------解决方案--------------------
是我没看明白吗?这样写不行吗?
select * 
from table1 a
 where a.nameid not in (select nameid from table2)
------解决方案--------------------
3楼正解
  相关解决方案