sql语句改如何匹配,请高手
通过以下语句:select TBLTYPE from SYS_TBLTYPE where TBLNAME= 'BIZ_SAF_CODE '
找出结果为:00060008
现在要通过这个来匹配出SYS_TBLTYPEDIC的字段为:0006与00060008这些字段。也就是他的父节点。如果搜出来是:000100010001 就要把TBLTYPEDIC表里的0001,00010001,00010001的所有节点都找出来。请问该如何匹配。
我这里是这么写的:但不对。找不出来。
select code from SYS_TBLTYPEDIC where code+ '% ' like (select TBLTYPE from SYS_TBLTYPE where TBLNAME= 'BIZ_SAF_CODE ')。请高手指点
------解决方案--------------------試下where charindex(code,(select TBLTYPE from SYS_TBLTYPE where TBLNAME= 'BIZ_SAF_CODE '))> 0
------解决方案--------------------select code from SYS_TBLTYPEDIC where left(code,4) in (select left(TBLTYPE,4) from SYS_TBLTYPE where TBLNAME= 'BIZ_SAF_CODE ')。
------解决方案--------------------喔 ,反過來行不
where (select TBLTYPE from SYS_TBLTYPE where TBLNAME= 'BIZ_SAF_CODE ') like code+ '% '