表结构如下
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在线等答案
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在线等答案
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)
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)
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)
或参考:
http://www.csdn.net/help/over.asp
http://topic.csdn.net/u/20080110/19/7cb462f1-cac6-4c28-848e-0a879f4fd642.html
=============================================================================
问题解决,请及时结贴。
正确结贴方法:
管理帖子-->给分-->输入密码-->结贴