我要查询某个表的字段信息
要求是
此字段包含另外一个表中以个字段的内容
比如
1
中国人
美国人
日本人
日本
是中
禁用
2
中中国人人
美国人
日本人
本日本名
我是中国人
我查询的是1表,等到的记录应该 除了 '禁用' 都检索到
要求是
此字段包含另外一个表中以个字段的内容
比如
1
中国人
美国人
日本人
日本
是中
禁用
2
中中国人人
美国人
日本人
本日本名
我是中国人
我查询的是1表,等到的记录应该 除了 '禁用' 都检索到
解决方案 »
- Oracle中的rn是什么?
- oracle存储过程,输出参数为数组的问题?看在圣诞节苦苦钻研的份上,救命啊~~
- 关于oracle数据库复制的问题(急)
- 求sql语句
- XP SP2安装oracle8 professional版,出现stopsrvc.vrf(78):Type mismatch 错误,急
- Oracle 初学者的简单问题,如何输入表中的数据
- 请教Oracle字符集转换问题。。。问题紧急!请高手执教。
- 如何复制表中某一字段数据?
- 取最大流水号加一再insert用一句sql行吗
- 我用得function时返回一个游标的,操作多了,显示游标超过最大数
- 关于kill掉连接进程一直不能清除。
- 如何测试我的oracle客户端能连上服务器?
where not exists
(select 1 from t2 where t2.n like '%'||t1.n||'%')
楼上逻辑错了,多了个not
SQL> select * from table1;
NAME
--------------------
中国人
美国人
日本人
日本
是中
禁用
6 rows selected
SQL> select * from table2;
NAME
--------------------
中中国人人
美国人
日本人
本日本名
我是中国人
SQL>
SQL> select *
2 from table1 t1
3 where exists(select * from table2 t2 where t2.name like '%'||t1.name||'%');
NAME
--------------------
中国人
美国人
日本人
日本
是中
NAME
--------------------
中国人
美国人
日本人
日本
是中
这个吧!!!
SQL> create table table01( name varchar2(300));
Table created
SQL> insert into table01 values('中国人');
1 row inserted
SQL> insert into table01 values('美国人');
1 row inserted
SQL> insert into table01 values('日本人');
1 row inserted
SQL> insert into table01 values('日本');
1 row inserted
SQL> insert into table01 values('是中');
1 row inserted
SQL> insert into table01 values('禁用');
1 row inserted
SQL> commit;
Commit complete
SQL> create table table02( name varchar2(300));
Table created
SQL> insert into table02 values('中中国人人');
1 row inserted
SQL> insert into table02 values('美国人');
1 row inserted
SQL> insert into table02 values('日本人');
1 row inserted
SQL> insert into table02 values('本日本名');
1 row inserted
SQL> insert into table02 values('我是中国人');
1 row inserted
SQL> commit;
Commit completeSQL> select * from table01;
NAME
----------------------------------------------------
中国人
美国人
日本人
日本
是中
禁用6 rows selectedSQL> select * from table02;NAME
-----------------------------------------------------
中中国人人
美国人
日本人
本日本名
我是中国人SQL> select * from table01 a
2 where exists(select 1 from table02 b
3 where instr(b.name,a.name,1) !=0
4 );NAME
-----------------------------------------------------
中国人
美国人
日本人
日本
是中SQL> drop table table01;
Table droppedSQL> drop table table02;
Table droppedSQL>
where a.cname like '%'||a1.tname||'%' ;select a.cname,a1.tname,instr(a1.tname,a.cname,1,1)from a,a1 where instr(a1.tname,a.cname,1,1)>0