Question
Multple Joins
I have the following as a query on my web page:
SELECT cast(CHG_ACTUAL_AMT as char) as Amount, CHG_TRAN_CD as trans , CHG_SEQ_NBR as seq, CHG_DT_OF_SERVICE as DOS, CHG_POST_DT as PST, CHG_CURRENT_FC as fc, CHG_PERF_DEPT_CD AS dept, CHG_PERF_PHYS_NBR as phys, CHG_PROC_CD as pcode, DISPLAY_NM AS pname, CHG_PAT_NBR AS pnum
FROM AR_CHARGE AS ar
LEFT outer JOIN MPI_XREF as mx on AR.CHG_CUST_NBR = mx.CUST_NBR and AR.CHG_PAT_NBR = mx.PAT_NBR
join MPI as mi on MPI_XREF.MPI_NBR = mi.MPI_NBR and MPI_XREF.MPI_SET = mi.MPI_SET
WHERE CHG_GUAR_NBR = #url.ID#
and CHG_CUST_NBR = 04885
AND MPI_XREF.PAT_NBR <> 0
GROUP BY CHG_SEQ_NBR, CHG_ACTUAL_AMT, CHG_TRAN_CD, CHG_DT_OF_SERVICE, CHG_POST_DT, CHG_CURRENT_FC, CHG_PERF_DEPT_CD, CHG_PERF_PHYS_NBR, CHG_PROC_CD, DISPLAY_NM, CHG_PAT_NBR
As one can see I have a left outer join using two fields and a inner join using two fields. The error I get is:
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]The column prefix 'MPI_XREF' does not match with a table name or alias name used in the query
I do not know why it does not like my table MPI_XREF
Thanks.
SELECT cast(CHG_ACTUAL_AMT as char) as Amount, CHG_TRAN_CD as trans , CHG_SEQ_NBR as seq, CHG_DT_OF_SERVICE as DOS, CHG_POST_DT as PST, CHG_CURRENT_FC as fc, CHG_PERF_DEPT_CD AS dept, CHG_PERF_PHYS_NBR as phys, CHG_PROC_CD as pcode, DISPLAY_NM AS pname, CHG_PAT_NBR AS pnum
FROM AR_CHARGE AS ar
LEFT outer JOIN MPI_XREF as mx on AR.CHG_CUST_NBR = mx.CUST_NBR and AR.CHG_PAT_NBR = mx.PAT_NBR
join MPI as mi on MPI_XREF.MPI_NBR = mi.MPI_NBR and MPI_XREF.MPI_SET = mi.MPI_SET
WHERE CHG_GUAR_NBR = #url.ID#
and CHG_CUST_NBR = 04885
AND MPI_XREF.PAT_NBR <> 0
GROUP BY CHG_SEQ_NBR, CHG_ACTUAL_AMT, CHG_TRAN_CD, CHG_DT_OF_SERVICE, CHG_POST_DT, CHG_CURRENT_FC, CHG_PERF_DEPT_CD, CHG_PERF_PHYS_NBR, CHG_PROC_CD, DISPLAY_NM, CHG_PAT_NBR
As one can see I have a left outer join using two fields and a inner join using two fields. The error I get is:
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]The column prefix 'MPI_XREF' does not match with a table name or alias name used in the query
I do not know why it does not like my table MPI_XREF
Thanks.
