我这有两个表A,B
A:MSGSTR MSTIME
1,1,ertetsgd,wiu 2008-01-01 10:00:05
1,1,iuoijhghuy,564 2009-01-08 00:00:08
B:SSTR STIME
et 2008-01-01 09:59:59
hg 2009-01-08 00:00:00现在我要根据B表中的SSTR的内容查询A表中MSGSTR LIKE '% SSTR %'的记录,我该怎么写这个查询语句??100分相送,请笑纳
A:MSGSTR MSTIME
1,1,ertetsgd,wiu 2008-01-01 10:00:05
1,1,iuoijhghuy,564 2009-01-08 00:00:08
B:SSTR STIME
et 2008-01-01 09:59:59
hg 2009-01-08 00:00:00现在我要根据B表中的SSTR的内容查询A表中MSGSTR LIKE '% SSTR %'的记录,我该怎么写这个查询语句??100分相送,请笑纳
select a.msgstr, a.mstime
from a, b
where a.msgstr like '%' || b.sstr || '%';
select a.* from a,b where a.MSGSTR like '%'||b.SSTR||'%';
--或者
select a.* from a,b where instr(a.MSGSTR,b.SSTR)>0;
1,select a.* from a,b where a.MSGSTR like '%'||b.SSTR||'%';
2,select a.* from a,b where instr(a.MSGSTR,b.SSTR)>0;
where exists (
select * from b where a.MSGSTR like '%'|b.SSTR|'%'
)
2,select a.* from a,b where instr(a.MSGSTR,b.SSTR)>0;
3,select * from A where exists (select * from b where a.MSGSTR like '%'|b.SSTR|'%' )
这个三个都没有错,主要是你数据量和性能方面考虑 第三种的性能最差,第一和第二似乎差不多,目前没有大数据量无法准确测试,但是个人偏好第一种
第2种方法应该会比第一种效率高吧,oracle自带的函数,高人分析吧!