日期:2014-05-18 浏览次数:20424 次
select ISNULL(ClassName, '根分类') AS ClassName,ISNULL(NodeId,0) AS NodeId from Bst_ProClass where NodeId=some ( select ParentId from Bst_ProClass where NodeId=7)
create table ta(classname varchar(10),parentid int,nodeid int) insert into ta select 'a',1,2 insert into ta select 'b',0,7 go if exists(select 1 from ta where NodeId=some ( select ParentId from ta where NodeId=7)) select ISNULL(ClassName, '根分类') AS ClassName,ISNULL(NodeId,0) AS NodeId from ta where NodeId=some ( select ParentId from ta where NodeId=7) else select '根分类',0 drop table ta /* ------ ----------- 根分类 0 (所影响的行数为 1 行) */
------解决方案--------------------
some?
------解决方案--------------------
select ISNULL(a.ClassName, '根分类') AS ClassName,ISNULL(a.NodeId,0) AS NodeId from Bst_ProClass a right join Bst_ProClass t on t.parentid = a.nodeid
------解决方案--------------------
改成以下代码应该可以
select ISNULL(ClassName, '根分类') AS ClassName,ISNULL(NodeId,0) AS NodeId from Bst_ProClass where [color=#FF0000]isnull(NodeId,0)[/color]=some ( select ParentId from Bst_ProClass where NodeId=7)