Hi guys,
I am writing a query that will join my addr table to the main query and display everyone's address. The problem is several people do not have an address record so I want to do a LEFT JOIN and have them show up in the query anyways.
I keep getting syntax errors when I try to add in the LEFT JOIN. Can someone tell me what is wrong with this query structure? Thanks in advance.
Note: I have tried it with and without the AND before the LEFT JOIN and it doesn't work. I guess I don't know how to mix INNER and LEFT JOINS in the same query.
I am writing a query that will join my addr table to the main query and display everyone's address. The problem is several people do not have an address record so I want to do a LEFT JOIN and have them show up in the query anyways.
I keep getting syntax errors when I try to add in the LEFT JOIN. Can someone tell me what is wrong with this query structure? Thanks in advance.
Code:
SELECT A.MBR_SSN_NBR,
A.MBR_TOT_CNTRB_AMT,
C.MBR_F_NM,
C.MBR_L_NM,
C.MARITAL_STATUS
FROM DSNP.PR01_T_MBR_SYS A
INNER JOIN DSNP.PR01_T_MBR C ON A.MBR_SSN_NBR=C.MBR_SSN_NBR
and
LEFT JOIN DSNP.PR01_T_EMPR_ADDR D on A.MBR_SSN_NBR = D.MBR_SSN_NBR
AND A.MBR_STAT_CD = '1'
AND A.MBR_TOT_CNTRB_AMT > 0.00
AND NOT EXISTS (SELECT 1 FROM DSNP.PR01_T_BENEF b WHERE B.MBR_SSN_NBR = A.MBR_SSN_NBR)
Note: I have tried it with and without the AND before the LEFT JOIN and it doesn't work. I guess I don't know how to mix INNER and LEFT JOINS in the same query.