Home > database >  Oracle statement written for help
Oracle statement written for help

Time:09-22

The great god help, genuflect is begged thought for a long time, don't know how to do,
Three tables, A, E, F, such as:

Watch A table E F
EMPLID ACID ACID ACID_PAR EMPLID ACID DECR
01 08 08 01 08 AA
02 09 09 02 10 AA
10 09
03 November 11

The table if the table has A corresponding ACID_PAR, E is to find A table with the corresponding ACID F; The EMPLID 03 in table A, for example, there is no corresponding in table F, but the results should show ""

Should eventually selected results:
EMPLID ACID DECR
01 08 AA
02 10 AA
03 11

What should be how to write, is studied for a long time, to run for a long time, are not out the results,,,

CodePudding user response:

CodePudding user response:

 
- this mean?

Select * from A
Left on the join E A.a cid=E.a cid
Left the join F on A.e mpid=F.e mpid;

CodePudding user response:

The select a.e mplid, a.a cid, f.D ECR
From a, e, f
Where a.a cid=e.a cid (+)
And a.e mplid=f.e mplid (+)
The order by a.e mplid

CodePudding user response:

A look at the result is a superposition of two tables together with the union all, SQL is as follows: look at the full does not meet the conditions ( visual and the results you said)
The select F.E MPLID emplid, F.A CID acid, F.D ECR decr
From A, E, F
WHERE A.A CID=E.A CID
And E.A CID_PAR is not NULL
And E.A CID=F.A CID
The union
The select A.E MPLID emplid, A.A CID acid, null decr
From A
Where not the exists (select 1 from F the where A.E MPLID=F.E MPLID)

CodePudding user response:

Don't understand how this line is even out
02 10 AA
  • Related