我在pl/sql develpoer上运行下面一条sql语句:
select t2.El_Name as resource_name,t2.el_labelid as resource_label,t2.El_Depoisit as resource_store,t1.Borrow_Date as resource_time from intel.CS_EleBorrowInfo t1,intel.CS_ElectronicInfo t2 where t1.Borrow_ObjectID = t2.El_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.Film_Name as resource_name,t2.Film_LableID as resource_label,t2.Film_Depoisit as resource_store,t1.Borrow_Date as resource_time from intel.CS_FilmBorrowInfo t1,intel.CS_FilmInfo t2 where t1.Borrow_ObjectID = t2.Film_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.ReliefMap_Name as resource_name,t2.ReliefMap_LabelID as resource_label,t2.ReliefMap_Depoisit as resource_store,t1.Borrow_Date as resource_time from CS_MapBorrowInfo t1,CS_ReliefMapInfo t2 where t1.Borrow_ObjectID = t2.ReliefMap_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.Book_Name as resource_name,t2.Book_LableID as resource_label,t2.Book_Depoisit as resource_store,t1.Borrow_Date as resource_time from CS_BookBorrowInfo t1,CS_BookInfo t2 where t1.Borrow_ObjectID = t2.Book_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.Maga_Name as resource_name,t2.Maga_LabelID as resource_label,t2.Maga_Depoisit as resource_store,t1.Borrow_Date as resource_time from CS_MagaBorrowInfo t1,CS_MagazineInfo t2 where t1.Borrow_ObjectID = t2.Maga_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd')结果出现错误。错误在:
union select t2.Film_Name as resource_name,t2.Film_LableID as resource_label,t2.Film_Depoisit as resource_store,t1.Borrow_Date as resource_time from intel.CS_FilmBorrowInfo t1,intel.CS_FilmInfo t2 where t1.Borrow_ObjectID = t2.Film_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd')
这一部分,具体的错误信息是"t2","Film_LableID" 无法识别的标识符但是很奇怪,这个字段在intel.CS_FilmInfo表中是存在的。而且我把这一部分的所有的t2全部改为t3,竟然就没有错误了。这太奇怪了!

解决方案 »

  1.   

    我把格式整理一下:select t2.El_Name as resource_name,t2.el_labelid as resource_label,t2.El_Depoisit as resource_store,t1.Borrow_Date as resource_time from intel.CS_EleBorrowInfo t1,intel.CS_ElectronicInfo t2 where t1.Borrow_ObjectID = t2.El_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.Film_Name as resource_name,t2.Film_LableID as resource_label,t2.Film_Depoisit as resource_store,t1.Borrow_Date as resource_time from intel.CS_FilmBorrowInfo t1,intel.CS_FilmInfo t2 where t1.Borrow_ObjectID = t2.Film_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.ReliefMap_Name as resource_name,t2.ReliefMap_LabelID as resource_label,t2.ReliefMap_Depoisit as resource_store,t1.Borrow_Date as resource_time from CS_MapBorrowInfo t1,CS_ReliefMapInfo t2 where t1.Borrow_ObjectID = t2.ReliefMap_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.Book_Name as resource_name,t2.Book_LableID as resource_label,t2.Book_Depoisit as resource_store,t1.Borrow_Date as resource_time from CS_BookBorrowInfo t1,CS_BookInfo t2 where t1.Borrow_ObjectID = t2.Book_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd') union select t2.Maga_Name as resource_name,t2.Maga_LabelID as resource_label,t2.Maga_Depoisit as resource_store,t1.Borrow_Date as resource_time from CS_MagaBorrowInfo t1,CS_MagazineInfo t2 where t1.Borrow_ObjectID = t2.Maga_ID and t1.Borrow_UserID=3 and t1.return_date is null and t1.Borrow_Date<to_date('2007-7-1','yyyy-mm-dd')其实这个就是五个select语句结合在一起,一点也不复杂。错误就出现在第二个select语句
      

  2.   

    看一下其他的别名为t2的表中是不是也有Film_LableID这个字段
      

  3.   

    字段敲错了吧?你的五个表中的ID字段有的是:LableID,有的是:LabelID 仔细确认一下
      

  4.   

    quote:看一下其他的别名为t2的表中是不是也有Film_LableID这个字段  其它表中不可能有Film_LableID这个字段