select classId,className,tchrId1,tchrId2,b.tchrName1,c.tchrName2 from class a,(select tchrId,tchrname tchrname1 from tchr where tchrId=a.tchrid1) b,(select tchrId,tchrname tchrname2 from tchr where tchrId=a.tchrid2) c where a.tchrID1=b.tchrID and a.tchId1=c.tchId
select a.classId,a.className,a.tchrId1,a.tchrId2,a.tchrName1,b.tchrName2
from class a,tchr b
where a.tchrId1=b.tchrId
如果a.tchrId1和b.tchrId是对应的,就没有错了
select classId,className,tchrId1,tchrId2,b.tchrName1,c.tchrName2 from class a,(select tchrId,tchrname tchrname1 from tchr where tchrId=a.tchrid1) b,(select tchrId,tchrname tchrname2 from tchr where tchrId=a.tchrid2) c where a.tchrID1=b.tchrID and a.tchId2=c.tchId;
aaa.tchrId2, bbb.tchrName AS tchrName1,
bbb_1.tchrName AS tchrName2
FROM aaa ,bbb,bbb bbb_1
where aaa.tchrId1 = bbb.tchrId(+)
and aaa.tchrId2 = bbb_1.tchrId(+);
select classId,className,tchrId1,tchrId2,
(select b.tchrname from tchr b where b.tchrid = a.tchrid1) tchrName1,
(select c.tchrname from tchr c where c.tchrid = a.tchrid2) tchrName2
from class a
select classId,className,tchrId1,tchrId2,nvl(b.tchrName1,'null') tchrname2,nvl(c.tchrName2,'null') tchrname2 from class a,(select tchrId,tchrname tchrname1 from tchr where tchrId=a.tchrid1) b,(select tchrId,tchrname tchrname2 from tchr where tchrId=a.tchrid2) c where a.tchrID1=b.tchrID(+) and a.tchId2=c.tchId(+);
beckham兄
select a.class_Id,a.class_Name,a.charge_Id1,a.charge_Id2,b.tchr_Name,c.tchr_Name from class_info a,(select tchr_Id,tchr_Name from tchr_info where tchrId=class_info.charge_Id1) b,(select tchr_Id,tchr_Name from tchr_info where tchr_Id=class_info.charge_Id2) c where
*
a.charge_Id1=b.tchr_Id and a.charge_Id2=c.tchr_Id
ERROR 位于第 1 行:
ORA-00904: 无效列名
呵呵,不知是哪出错了
数据库中class表是class_info,tchr表是tchr_info,charge_id引用tchr_id
不要以偏概全啊 :)