日期:2014-05-17  浏览次数:20664 次

急!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楼正解