日期:2014-05-19  浏览次数:20555 次

关于select与join语句,大家帮个忙
一共有四个表,为表event,txpc,rxpc,ecio     以上表主键均为oid,外键是the_event
现在我想把event表作为参考,把txpc,rxpc中的表对应值依次加入(就是left   join功能)但是对于ecio表我想对它的number字段进行筛选,筛选后的得到的结果后再与前面left   jion.
不知道我这样说大家能不能理解~~~我刚学,见谅,是不是像下面这样编呢?

select         e.*,         t.*   ,r.*   ,o.*
      from           "Event "     as   e  
  left   join       "TXPC "   as   t       on     e.oid=t.the_event
  left   join       "rxpc "   as   r       on     e.oid=r.the_event
  left   join       (seclet   ecio.*   from   ecio     where   "number "=257)   as   o
                                                      on     e.oid=o.the_event


------解决方案--------------------
select *
from "Event " as e
left join "TXPC " as t on e.oid=t.the_event
left join "rxpc " as r on e.oid=r.the_event
left join (select * from ecio where "number "=257) as o
on e.oid=o.the_event

语法可以
------解决方案--------------------
select
e.*,
t.*,
r.*,
o.*
from Event as e
left join TXPC as t on e.oid=t.the_event
left join rxpc as r on e.oid=r.the_event
left join ecio as o on e.oid=o.the_event and o.number = 257
------解决方案--------------------
帮顶