排列组合查询算法

死不回头 2017-03-21 04:08:44
例如有几种药物,a,b,c,d,e......;有一个配伍禁忌的表,就是那两种药不能在一起使用,表的名字比如叫 table,里面列为:药品1,药品2,配伍禁忌说明。
用啥算法能最快的查出a,b,c,d,e.....,左右的可能配伍禁忌(在table中定义好的)
...全文
158 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
js14982 2017-03-21
  • 打赏
  • 举报
回复
with t as
(select 'a' id from dual union all
select 'b' id from dual union all
select 'c' id from dual union all
select 'd' id from dual union all
select 'e' id from dual 
), table1 as
(
select 'a' id1,'e' id2,null jj from dual union all
select 'b' id1,'f' id2,null jj from dual 
)
select 
     c.*
from t a,t b ,table1 c
where a.id = c.id1
  and b.id = c.id2
;

17,086

社区成员

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

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