求教一个语句

[复制链接]
查看11 | 回复7 | 2007-4-25 04:02:08 | 显示全部楼层 |阅读模式
表结构如下:
create table oga_file
(


oga01 varchar2(16) NOT NULL, /*出货单号
*/
oga03 varchar2(10),
/*帐款客户编号
*/
oga04 varchar2(10),
/*送货客户编号
*/
);

create table occ_file
(
occ01 varchar2(10) NOT NULL, /*客户编号
*/
occ02 varchar2(40),
/*客户简称
*/
occ18 varchar2(80),
/*公司全名
*/
occ231varchar2(255), /*账款地址
*/
occ241varchar2(255), /*送货地址
*/
);
需要得出结果如下:
出货单号,账款客户编号,账款客户简称,公司全名,账款地址,送货客户编号,送货客户简称,送货客户公司全名,送货地址

请帮忙
回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层
关联
回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层
selectoa.oga01,
oa.oga03,
(select oc.occ01 from occ_file oc where oc.occ01=oa.oga03),
(select oc.occ02 from occ_file oc where oc.occ01=oa.oga03),
(select oc.occ18 from occ_file oc where oc.occ01=oa.oga03),
(select oc.occ231 from occ_file oc where oc.occ01=oa.oga03),
oa.oga04,
(select oc.occ01 from occ_file oc where oc.occ01=oa.oga03),
(select oc.occ02 from occ_file oc where oc.occ01=oa.oga03),
(select oc.occ18 from occ_file oc where oc.occ01=oa.oga03),
(select oc.occ241 from occ_file oc where oc.occ01=oa.oga03)
from oga_file oa
要求 occ_file.occ01唯一
回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层

如何提问, 先看看 "http://www.itpub.net/thread-1348543-1-1.html"!

回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层
这个是很简单的关联吧...
回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层
没事看看书吧
回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层
感谢2楼的提醒,感谢3楼的帮忙。
自己写出来了。那些“高手”们,也感谢你们的批评。

select a.oga01,a.oga04, a.occ02,a.occ18,a.occ241,b.oga03,b.occ02,b.occ18,b.occ231 from
(select oga01,oga04,occ02,occ18,occ241
from oga_file,occ_file
where oga04=occ01
) a
,
(select oga01,oga03,occ02,occ18,occ231
from oga_file,occ_file
where oga03=occ01
) b
where a.oga01=b.oga01
回复

使用道具 举报

千问 | 2007-4-25 04:02:08 | 显示全部楼层
SELECT of1.oga01
, of2.occ01
, of2.occ02
, of2.occ18
, of2.occ231
, of2.occ241
, of3.occ01
, of3.occ02
, of3.occ18
, of3.occ231
, of3.occ241
FROM oga_file of1
, occ_file of2
, occ_file of3
WHEREof1.oga03 = of2.occ1
ANDof1.oga04 = of3.occ1
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行