Hi,
I am trying to create a SQL Query accessing a SQL database combining two tables together. I was able to successfully create the Union Query however, now I want to add a parameter that is the same in both queries. I can get it in the first part but in the second half, I get an error message "The multi-part identifier "MRI_Journal.Period" could not be bound. The query I have used is below:
SELECT
MRI_GHIS.ENTITYID,
MRI_GHIS.ACCTNUM,
MRI_GHIS.PERIOD,
MRI_GHIS.REF,
MRI_GHIS.SOURCE,
MRI_GHIS.AMT,
MRI_GHIS.DESCRPN
FROM MRIData.dbo.MRI_GHIS MRI_GHIS
WHERE (MRI_GHIS.ENTITYID='C01400') AND (MRI_GHIS.ACCTNUM Like '%CP1810344%') AND (MRI_GHIS.PERIOD>=?) and (MRI_GHIS.period <=?)
UNION
SELECT
MRI_JOURNAL.ENTITYID,
MRI_JOURNAL.ACCTNUM,
MRI_JOURNAL.PERIOD,
MRI_JOURNAL.REF,
MRI_JOURNAL.SOURCE,
MRI_JOURNAL.AMT,
MRI_JOURNAL.DESCRPN
FROM MRIData.dbo.MRI_JOURNAL MRI_JOURNAL
WHERE (MRI_JOURNAL.ENTITYID='C01400') AND (MRI_JOURNAL.ACCTNUM Like '%CP1810344%') and (MRI_JOURNAL.PERIOD >=?)
I am trying to create a SQL Query accessing a SQL database combining two tables together. I was able to successfully create the Union Query however, now I want to add a parameter that is the same in both queries. I can get it in the first part but in the second half, I get an error message "The multi-part identifier "MRI_Journal.Period" could not be bound. The query I have used is below:
SELECT
MRI_GHIS.ENTITYID,
MRI_GHIS.ACCTNUM,
MRI_GHIS.PERIOD,
MRI_GHIS.REF,
MRI_GHIS.SOURCE,
MRI_GHIS.AMT,
MRI_GHIS.DESCRPN
FROM MRIData.dbo.MRI_GHIS MRI_GHIS
WHERE (MRI_GHIS.ENTITYID='C01400') AND (MRI_GHIS.ACCTNUM Like '%CP1810344%') AND (MRI_GHIS.PERIOD>=?) and (MRI_GHIS.period <=?)
UNION
SELECT
MRI_JOURNAL.ENTITYID,
MRI_JOURNAL.ACCTNUM,
MRI_JOURNAL.PERIOD,
MRI_JOURNAL.REF,
MRI_JOURNAL.SOURCE,
MRI_JOURNAL.AMT,
MRI_JOURNAL.DESCRPN
FROM MRIData.dbo.MRI_JOURNAL MRI_JOURNAL
WHERE (MRI_JOURNAL.ENTITYID='C01400') AND (MRI_JOURNAL.ACCTNUM Like '%CP1810344%') and (MRI_JOURNAL.PERIOD >=?)