Left Join the where clause

I have 3 tables A, B and C

alt text

I do this: - / * There is no relationship between table A and table B. Table A is only used to provide C.Profile values ​​* / 1st step) D <---- Select * from C, where Profile = 1 / / want to specify a specific ProID (I successfully extracted it from table A)

2nd step) Exit <--- Select B.sname, D.Status from B Left Join D On B.ID = D.ID

so that the output looks like the required output table shown above: -

Can I do this using a single query? as?

+3
source share
1 answer

You mean the subquery:

Select B.DirName,D.Status 
from B Left Join (
    Select * 
    from C 
    where ProId=1) As D 
On B.DirID=D.DirID

It is best to use a list of fields rather than *

+3

Source: https://habr.com/ru/post/1759295/


All Articles