Students table structure as
The name | every | classIDBF
Zhang SAN | | null 01
Li si | | 02 02
Fifty | null | 03
Class table structure as
The name | id
A class of | 01
Class 2 | 02
Class 3 | 03
Now, I want to check each of the students which is corresponding to the class, it is
Select the student table. The name, class table. The name from the student table, class table where the student table. Every class table. Id
However, in this way, can't check out of a class,
So, I want to achieve this, first reading
students. Every class table. Id
If the not value, then query again
students table. ClassIDBF=class table. Id
Then read value,
If judgment is similar to c #, do you have a big meeting?
CodePudding user response:
The select a.n ame, b.n ame
From the students watch a
Left the join table b class on NVL (a.c lassID, a.c lassIDBF)=b.i d
CodePudding user response:
I haven't tried, if the above doesn't work, try this one,The select a.n ame
, b.n ame
The from (
Select the name
And NVL (every, classIDBF) every
, classIDBF
From the students watch
) a
Left the join table b class on a.c lassID=b.i d