比如表中有个name字段
name
张三
张三1
张三2
李四
王五
王五1
我想通过sql语句找出具有包含关系的记录,如
张三
张三1
张三2
王五
王五1 我用的是mysql数据库

解决方案 »

  1.   

    select * from 比如表 a 
    where exists (select 1 from 比如表 where instr(name,a.name));
      

  2.   

    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
    http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
      

  3.   

    select * from table a where exists(select name from table where insert(name,a.name))
    提示错误
      

  4.   

    贴出你的错误信息。 不会你的表名真的就 table 吧。需要改成你自己的字段名,表名。
      

  5.   

    select * from rawdata0 a where exists (select 1 from rawdata0 where insert(name,a.name))rawdata0是我的表名,用mysql-front执行,提示
      

  6.   


     where instr(name,a.name));老兄啊,你复制都复制错了啊。
      

  7.   

    我没复制,我是自己打的,我太粗心了,看到ins就习惯的写成了insert
    抱歉抱歉,让你帮我找这么低级的错误还有,问题解决了,谢谢
    结贴