我这有两个表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分相送,请笑纳

解决方案 »

  1.   

    select a.msgstr,a.mstime from a join b on a.msgstr like '%'||b.sstr||'%';
      

  2.   

    WHERE INSTR(A.MSGSTR, B.SSTR) > 0
      

  3.   


    select a.msgstr, a.mstime 
      from a, b
     where a.msgstr like '%' || b.sstr || '%';
      

  4.   


    select a.* from a,b where a.MSGSTR like '%'||b.SSTR||'%';
    --或者
    select a.* from a,b where instr(a.MSGSTR,b.SSTR)>0;
      

  5.   


    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;
      

  6.   

    select * from A
      where exists (
              select * from b where a.MSGSTR like '%'|b.SSTR|'%'
      )
      

  7.   

    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;
      

  8.   

    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;
    3,select * from A where exists (select * from b where a.MSGSTR like '%'|b.SSTR|'%' )
    这个三个都没有错,主要是你数据量和性能方面考虑 第三种的性能最差,第一和第二似乎差不多,目前没有大数据量无法准确测试,但是个人偏好第一种
      

  9.   

    select a.* from a,b where a.MSGSTR like '%'||b.SSTR||'%'; 
      

  10.   

    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; 
    第2种方法应该会比第一种效率高吧,oracle自带的函数,高人分析吧!