开发者

Oracle: What's the problem with this join?

I can't get this Join to work in Oracle开发者_如何学运维. Can't figure it out, why is it?

SELECT E."ci", E."nombre"
FROM EMPLEADO E
WHERE E."ci" IN (SELECT E."cisupervisor" FROM EMPLEADO E);


INNER JOIN empleado ON "ci"= T."ciempleado"

SELECT E."nombre",E."apellido",P."nombreproy"
FROM EMPLEADO E, PROYECTO P
WHERE E."cisupervisor" IN (SELECT E."ci"
FROM EMPLEADO E, PROYECTO P, TRABAJAEN T
WHERE E."sexo"='F' AND E."ci"=T."ciempleado" AND T."horas">60 AND T."codproy"=P."codproy" AND P."fechaini"=2010
);


As @cyberwiki correctly noted, you are basically trying to join two individual queries.

The first one ends at line 3 because it's terminated with a semicolon.

This part:

INNER JOIN empleado ON "ci"= T."ciempleado"

doesn't work on it's own since you need a where clause after your join if you want more conditions.

Everything after this part is another query that executes well on its own.

You can try this online validator and you'll see that lines 1-3 and everything after inner join are valid SQL 2003 statements, although your entire query isn't.

It seems to me you need to work a bit more on understanding how joins work. You can't just join two individual queries.

I've done a bit of reorganizing with your query and this version will pass, although it might not be what you're looking for:

SELECT E."ci", E."nombre"
FROM EMPLEADO E

INNER JOIN empleado ON "ci"= T."ciempleado"

where E."ci" IN (SELECT E."cisupervisor" FROM EMPLEADO E) and 

(SELECT E."nombre",E."apellido",P."nombreproy"
FROM EMPLEADO E, PROYECTO P
WHERE E."cisupervisor" IN (SELECT E."ci"
FROM EMPLEADO E, PROYECTO P, TRABAJAEN T
WHERE E."sexo"='F' AND E."ci"=T."ciempleado" AND T."horas">60 AND T."codproy"=P."codproy" AND P."fechaini"=2010
));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜