大虾们,小弟只会写简单的一些sql,现有两条sql想糅合成一条,希望大家给些提示第一条:
select A.id from t_item A , t_xxx B
where A.type = 2 and A.itemtype = 5 and A.id= B.itemid第二条:
select A.id from t_item A, t_yyy C
where A.type = 2 and A.itemtype = 6 and A.id = C.itemid我个人觉得哈,这个我最迷茫的地方在这里: 第一条 sql里 是在 A.itemtype = 5 的情况下 去查找 A.id= B.itemid 这个的
第二条 sql里 是在 A.itemtype = 6 的情况下 去查找 A.id = C.itemid 这个的而且吧,A表中的itemtype属性 还有 1,2,3,4 这四种属性值求大虾给些提示
select A.id from t_item A , t_xxx B
where A.type = 2 and A.itemtype = 5 and A.id= B.itemid第二条:
select A.id from t_item A, t_yyy C
where A.type = 2 and A.itemtype = 6 and A.id = C.itemid我个人觉得哈,这个我最迷茫的地方在这里: 第一条 sql里 是在 A.itemtype = 5 的情况下 去查找 A.id= B.itemid 这个的
第二条 sql里 是在 A.itemtype = 6 的情况下 去查找 A.id = C.itemid 这个的而且吧,A表中的itemtype属性 还有 1,2,3,4 这四种属性值求大虾给些提示
解决方案 »
- 在oracle server中,怎样建view 连接SQL server数据库
- SQL SERVER分页存储过程转为oracle 分页存储过程
- 关于sql-server到oracle导数据问题
- orcale pl/sql 中 ":" 符號用加在某變量前是作么用的
- 请问建表的时候如果给字段加上注释?
- 请问各位大狭这句很简单要求的sql怎么写?谢谢 ^0^
- 请各位看看,这到底是什么原因!谢谢了!帮帮忙!·
- about oracle 数据导出的问题,请教各位高手。
- 高手请指教:是否有关于oracle 高级队列的开发学习资料?
- 哪位大侠能够解决 ODG-05271 问题?(100分)在线对待。。。
- oracle在客户端备份和服务器端备份的一个相关问题.
- 查询的字段名显示问题
SELECT A.id
FROM t_item A, t_xxx B, t_yyy C
WHERE A.id = B.itemid AND
A.id = C.itemid AND
A.type = 2 AND
(A.itemtype = 5 OR A.itemtype = 6)
--2.
select A.id from t_item A , t_xxx B
where A.type = 2 and A.itemtype = 5 and A.id= B.itemid
union all
select A.id from t_item A, t_yyy C
where A.type = 2 and A.itemtype = 6 and A.id = C.itemid
你的第二条sql可以实现哈~! 无限感激...
select A.id from t_item A , t_xxx B
where A.type = 2 and A.itemtype = 5 and A.id= B.itemid第二条:
select A.id from t_item A, t_yyy C
where A.type = 2 and A.itemtype = 6 and A.id = C.itemid
select A.id from t_item A join t_yyy C on A.id = C.itemid
join t_xxx B on A.id= B.itemid
where A.type = 2 and A.itemtype in(5,6)
where A.type = 2 and A.itemtype = 5 and A.id= B.itemid
union all
select A.id from t_item A, t_yyy C
where A.type = 2 and A.itemtype = 6 and A.id = C.itemid