求一SQL,要求用一条SQL语句可否做到

moshangchen 2004-06-22 10:48:58
要求用一条SQL语句可否做到:

id path
01 0001
02 00010001
03 00010002
04 0002
05 00020001
06 00020002
07 000200010001
==================
如果已知path=000200010001过滤完后应该是
id path
04 0002
06 00020001
...全文
118 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
CsdnRob 2004-07-02
  • 打赏
  • 举报
回复
我尝试了一下,编译后用两台机器测试,可是在客户端显示连接成功后并没有回放出服务器端传来的视频图像啊
moshangchen 2004-06-22
  • 打赏
  • 举报
回复
sunnyrain(旭雨)
=============================

select * from table where instr('000200010001',path)=1
这条语句好,精炼
moshangchen 2004-06-22
  • 打赏
  • 举报
回复
楼上的写的不错,不过声明:path最长可以是80位,也就是可以分20级
sunnyrain 2004-06-22
  • 打赏
  • 举报
回复
错了,应该是 select * from table where instr('000200010001',path)=1
sunnyrain 2004-06-22
  • 打赏
  • 举报
回复
select * from table where instr('000200010001',path)>0
freddy2003 2004-06-22
  • 打赏
  • 举报
回复
select it,path from t4 where substr(path,1,4)=substr('000200010001',1,4) and decode(substr(path,5,4),null,substr('000200010001',5,4),substr(path,5,4))=substr('000200010001',5,4) and substr(path,9,4) is null
moshangchen 2004-06-22
  • 打赏
  • 举报
回复
通过Path找到所以其上级的id,根级的path是4位
必如已知path=000200010001过滤完后应该是

id path
================================
04 0002
06 00020001
freddy2003 2004-06-22
  • 打赏
  • 举报
回复
你要把规律说出来
moshangchen 2004-06-22
  • 打赏
  • 举报
回复
呵呵,刚才没有表达清楚可能
id path
01 0001
02 00010001
03 00010002
04 0002
05 00020001
06 00020002
07 000200010001
08 000200010002
09 0002000100020001
。。。。。。
baojianjun 2004-06-22
  • 打赏
  • 举报
回复
select id,path from table
where path<>'000200010001'
and path like '0002%'

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧