表结构如下
id                  n1                               n2                    status
1               0000,0101                           0102                    0
2               0000,0001,0101,0201                 0010,0020,0102          0n1,n2为字符串类型,大小按序排列,status 整型
写一句SQL 判断 如果n1,n2的值包含先前数据库已经存在的n1,n2的值,那么status=1
例如:0000,0101 包含在0000,0001,0101,0201中,0102包含在0010,0020,0102中,那么就update set status=1 where id=2在线等答案

解决方案 »

  1.   

    select *
    from tableName a 
    where EXISTS (select id from tableName where instr(n1,a.n1)>0 and instr(n2,a.n2)>0 and id != a.id)
    == 思想重于技巧 ==
      

  2.   

    update tableName a 
    set status=1
    where EXISTS (select id from tableName where instr(n1,a.n1)>0 and instr(n2,a.n2)>0 and id != a.id)
    == 思想重于技巧 ==
      

  3.   

    楼上解决 顶~
    update tableName a 
    set status=1
    where EXISTS (select id from tableName where position(a.n1 in n1)>0 and position(a.n2 in n2)>0 and id != a.id)
      

  4.   

    如果您问题已经得解决,请您及时结帖给分,以感谢帮助您的朋友。 结帖方法:点击版面右上方或右下方 <管理> ,进入页面后就可以输入密码,分别给分,结帖。 
     或参考:
    http://www.csdn.net/help/over.asp
    http://topic.csdn.net/u/20080110/19/7cb462f1-cac6-4c28-848e-0a879f4fd642.html
    =============================================================================
    问题解决,请及时结贴。  
     正确结贴方法:    
     管理帖子-->给分-->输入密码-->结贴
    == 思想重于技巧 ==