首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

A SQL query question for oracle。解决方案

2012-05-24 
A SQL query question for oracle。物料表:idname----------001物料1002物料2仓库表:sididqty------------0

A SQL query question for oracle。
物料表:
id name
----------
001 物料1
002 物料2

仓库表:
sid id qty
------------
01 001 2
02 001 3
03 001 5
01 002 1
02 002 2
03 002 4

我期望的查询结果是:
id name sid qty
--------------------
001 物料1 01 2
  02 3
  03 5
002 物料2 01 1
  02 2
  03 4

求各位指点谢谢!

[解决办法]
这样试试……

SQL code
select t1.id ,t1.name,t2.sid,t2.qty from (select * from t_wuliao order by id asc)t1 full join (select * from t_cangku  order by id,sid asc)t2on t1.id=t2.id and t2.sid ='01' 

热点排行