这条语句哪里错了?谢谢大家帮看看!!!!
- SQL code
select ISNULL(ClassName, '根分类') AS ClassName,ISNULL(NodeId,0) AS NodeIdfrom Bst_ProClass where NodeId=some ( select ParentId from Bst_ProClass where NodeId=7)
上面NodeId=7是我的测试,它对应的ParentId=0 ,数据库里面没有以0 开头的NodeId纪录,但是想用ISNULL怎么解决不了?谢谢大家怎么处理这个问题的
[解决办法]
- SQL code
create table ta(classname varchar(10),parentid int,nodeid int)insert into ta select 'a',1,2insert into ta select 'b',0,7goif 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 '根分类',0drop table ta/*------ ----------- 根分类 0(所影响的行数为 1 行)*/
[解决办法]
some?
[解决办法]
- SQL code
select ISNULL(a.ClassName, '根分类') AS ClassName,ISNULL(a.NodeId,0) AS NodeIdfrom Bst_ProClass aright join Bst_ProClass ton t.parentid = a.nodeid
[解决办法]
改成以下代码应该可以
- SQL code
select ISNULL(ClassName, '根分类') AS ClassName,ISNULL(NodeId,0) AS NodeIdfrom Bst_ProClass where [color=#FF0000]isnull(NodeId,0)[/color]=some ( select ParentId from Bst_ProClass where NodeId=7)