结构是这样的
我想获取b_pid<>0的,但是结果要不等于0的b_pid要等于b_id,b_entrance要存在,要一句的哦,我现在写的在循环里又查b_entrance,感觉会慢很多
解决方案 »
- 急!!!!!在线等高手解决转码问题
- 关于静态化页(c#.net)最挂方式.请N人指教
- datagird中checkbox 的问题????在线等!!!急!!
- asp.net学习图书介绍!!!!!
- gridview关于编号自动增长问题
- 如何将txt文本中的数据倒入倒sqlserver中。高人指点 在线等~~~~
- 咨询一下关于EXT.NET的资料等等
- MVC. 运行直接提示 未能找到E:/xx/xx/xx文件 .
- 出血急求VB.NET读数据库中一张表,动态生成treeview的代码.....还剩100分一次都给了
- WEB FORM之间传递参数的简单方法
- 【急求帮忙】配置在IIS7上的网站,访问的时候总是时好时坏
- 网站访问忽快忽慢的原因
b_pid=0的为父类,不等于0的为子类,其实就是想获取子类,但是获取到了还要得到子类所属父类的b_entrance
union
select * from
(
select * from table where b_id<>0 and isnull(b_pid,'')<>0 and isnull(b_entrance,'')<>''
) A where b_pid=b_id
select * from table where b_pid<>0 B) on A.b_id=B.b_pid where A.b_entrance is not null
我没这个数据库,没法测试,你试试有没有语法错误
select * from table where b_pid=b_id and b_id<>0 and isnull(b_entrance,'')<>''
where b_pid<>0 and b_id=b_pid and b_entrance is not null
你看行不行
(select distinct a.b_pid from tt where a.b_pid<>0) a
left join tt b
on a._pid=b.id and b_entrance is not null