A表: B表:
ID NAME ID NAME
1 A 2 B
2 B 3 C
3 C 4 D
要求得到以下结果:
ID NAME LY
1 A A
2 B AB
3 C AB
4 D B
请问如何写SQL语句,将A表和B表中的数据合并,并标示出其来自哪张表。其中LY列即来源列,注明来自A表或B表的数据
我的是oracle数据库,你的sql语句运行报错。另外,能否不用not in改用exists?