表A中有数据keyword(varchar),to(varchar),to对应B中的数据to(varchar),但是有所不同。
例如,A中to的形式为:     1_/abcdefg.txt
B中to的形式为:     /abcdefg.txt
也就是说,B中to跟A中的to从第三位开始是一样的
并且,A中的to包含B中的to,(B里面有的to表 A中都有,A里面的to表B里面不一定有)
我想先从A中提取keyword和to,再与B中的to进行比较。把那些相同的to的数据整到一个新表C里
请问我要怎么做?使用临时表或者复合语句都行,谢谢!(不知道我说清楚了没有)

解决方案 »

  1.   


    select keyword,b.to into #t from b,a where charindex(b.to,a.to)>0???
      

  2.   

    select keyword,b.to into #t from b,a where instr(b.to,a.to)>0
      

  3.   

    呃,ls两位的程序好像都不行
    我用的mysql,根本不识别charindex
    以上两个语句都报错:
     You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where instr (A.`to`, url)>0' at line 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where charindex (day_keyword_to.`to`, url)>0' at line 1